personal-bot 0.3.7 → 0.4.1
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 -2
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +4 -4
- package/docs/architecture/model-context.md +6 -3
- package/docs/guides/cross-harness-workers.md +5 -5
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +5 -5
- package/docs/hosts/claude-code.md +3 -3
- package/docs/hosts/codex-qoder.md +4 -2
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +349 -204
- package/lib/antigravity-plugin/lib/extension/cli.js +596 -572
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/antigravity-plugin/lib/extension/mcp.js +463 -379
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +2 -2
- package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
- package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +349 -204
- package/lib/extension/cli.js +596 -572
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +2 -2
- package/lib/extension/hosts/dsh/workspace.js +5 -5
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +61 -107
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +40 -24
- package/lib/extension/mcp.js +463 -379
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/integrations/agent-resources.js +3 -3
- package/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +182 -128
- package/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/services/history/summary-runner.js +3 -3
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/storage/history-files.js +3 -2
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +14 -16
- package/package.json +2 -2
- package/resources/agents/coordinator.md +2 -4
- package/resources/agents/general-purpose.md +2 -4
- package/resources/antigravity/skills/pbot/SKILL.md +6 -23
- package/resources/claude/skills/pbot/SKILL.md +6 -23
- package/resources/plugin/skills/pbot/SKILL.md +11 -3
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +6 -11
- package/resources/prompts/history-summary.md +6 -11
- package/resources/prompts/plugin-coordinator.md +1 -1
- package/resources/prompts/workspace.md +16 -23
- package/resources/skills/project-maintenance/SKILL.md +14 -21
- package/resources/skills/provider-connections/SKILL.md +23 -36
- package/resources/templates/workspace-agents.md +5 -13
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/mcp.ts +1 -1
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +2 -2
- package/src/extension/hosts/dsh/workspace.ts +5 -4
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +2 -2
- package/src/extension/hosts/pi/events.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +1 -11
- package/src/extension/mcp/tool-contract.ts +61 -108
- package/src/extension/mcp/workers.ts +39 -24
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +5 -5
- package/src/integrations/hosts/antigravity/adapter.ts +0 -1
- package/src/integrations/hosts/claude/adapter.ts +1 -2
- package/src/integrations/hosts/dsh/resources.ts +1 -1
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +3 -3
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +206 -135
- package/src/services/history/summary-dimensions/monthly.ts +1 -1
- package/src/services/history/summary-dimensions/session.ts +6 -3
- package/src/services/history/summary-runner.ts +3 -3
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -524,11 +524,11 @@ var require_valid = __commonJS({
|
|
|
524
524
|
"node_modules/semver/functions/valid.js"(exports, module) {
|
|
525
525
|
"use strict";
|
|
526
526
|
var parse = require_parse();
|
|
527
|
-
var
|
|
527
|
+
var valid15 = (version, options) => {
|
|
528
528
|
const v = parse(version, options);
|
|
529
529
|
return v ? v.version : null;
|
|
530
530
|
};
|
|
531
|
-
module.exports =
|
|
531
|
+
module.exports = valid15;
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
534
|
|
|
@@ -1937,7 +1937,7 @@ var require_semver2 = __commonJS({
|
|
|
1937
1937
|
var SemVer = require_semver();
|
|
1938
1938
|
var identifiers = require_identifiers();
|
|
1939
1939
|
var parse = require_parse();
|
|
1940
|
-
var
|
|
1940
|
+
var valid15 = require_valid();
|
|
1941
1941
|
var clean = require_clean();
|
|
1942
1942
|
var inc = require_inc();
|
|
1943
1943
|
var diff = require_diff();
|
|
@@ -1976,7 +1976,7 @@ var require_semver2 = __commonJS({
|
|
|
1976
1976
|
var subset = require_subset();
|
|
1977
1977
|
module.exports = {
|
|
1978
1978
|
parse,
|
|
1979
|
-
valid:
|
|
1979
|
+
valid: valid15,
|
|
1980
1980
|
clean,
|
|
1981
1981
|
inc,
|
|
1982
1982
|
diff,
|
|
@@ -2078,6 +2078,25 @@ var init_paths = __esm({
|
|
|
2078
2078
|
}
|
|
2079
2079
|
});
|
|
2080
2080
|
|
|
2081
|
+
// src/model/acp.ts
|
|
2082
|
+
var acpPermissionPolicies;
|
|
2083
|
+
var init_acp = __esm({
|
|
2084
|
+
"src/model/acp.ts"() {
|
|
2085
|
+
"use strict";
|
|
2086
|
+
acpPermissionPolicies = ["ask", "allow", "deny"];
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
|
|
2090
|
+
// src/model/workspace-config.ts
|
|
2091
|
+
var summaryConcurrency, historyLayouts;
|
|
2092
|
+
var init_workspace_config = __esm({
|
|
2093
|
+
"src/model/workspace-config.ts"() {
|
|
2094
|
+
"use strict";
|
|
2095
|
+
summaryConcurrency = { default: 3, max: 8 };
|
|
2096
|
+
historyLayouts = ["monthly", "flat"];
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
|
|
2081
2100
|
// src/storage/atomic-json.ts
|
|
2082
2101
|
import {
|
|
2083
2102
|
constants,
|
|
@@ -2210,29 +2229,10 @@ var init_atomic_json = __esm({
|
|
|
2210
2229
|
}
|
|
2211
2230
|
});
|
|
2212
2231
|
|
|
2213
|
-
// src/model/acp.ts
|
|
2214
|
-
var acpPermissionPolicies;
|
|
2215
|
-
var init_acp = __esm({
|
|
2216
|
-
"src/model/acp.ts"() {
|
|
2217
|
-
"use strict";
|
|
2218
|
-
acpPermissionPolicies = ["ask", "allow", "deny"];
|
|
2219
|
-
}
|
|
2220
|
-
});
|
|
2221
|
-
|
|
2222
|
-
// src/model/workspace-config.ts
|
|
2223
|
-
var summaryConcurrency, historyLayouts;
|
|
2224
|
-
var init_workspace_config = __esm({
|
|
2225
|
-
"src/model/workspace-config.ts"() {
|
|
2226
|
-
"use strict";
|
|
2227
|
-
summaryConcurrency = { default: 3, max: 8 };
|
|
2228
|
-
historyLayouts = ["monthly", "flat"];
|
|
2229
|
-
}
|
|
2230
|
-
});
|
|
2231
|
-
|
|
2232
2232
|
// src/services/workspace/workspace-config.ts
|
|
2233
|
-
import { readFileSync as
|
|
2233
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
2234
2234
|
import { mkdir as mkdir2, readFile as readFile2 } from "node:fs/promises";
|
|
2235
|
-
import { dirname as dirname3, join as
|
|
2235
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
2236
2236
|
function nonEmptyString(value) {
|
|
2237
2237
|
return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
|
|
2238
2238
|
}
|
|
@@ -2308,12 +2308,12 @@ function workspaceHistoryConfig(configuration) {
|
|
|
2308
2308
|
};
|
|
2309
2309
|
}
|
|
2310
2310
|
function workspaceConfigPath(root) {
|
|
2311
|
-
return
|
|
2311
|
+
return join3(root, ".pbot", "config.json");
|
|
2312
2312
|
}
|
|
2313
2313
|
function readWorkspaceHistoryLayoutSync(root) {
|
|
2314
2314
|
const path = workspaceConfigPath(root);
|
|
2315
2315
|
try {
|
|
2316
|
-
const content =
|
|
2316
|
+
const content = readFileSync3(path, "utf8");
|
|
2317
2317
|
const parsed = config(JSON.parse(content));
|
|
2318
2318
|
return workspaceHistoryConfig(parsed.history).layout;
|
|
2319
2319
|
} catch {
|
|
@@ -2447,9 +2447,9 @@ var init_summary_command = __esm({
|
|
|
2447
2447
|
|
|
2448
2448
|
// src/integrations/acp/executable.ts
|
|
2449
2449
|
import { accessSync, constants as constants2, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
2450
|
-
import { delimiter, isAbsolute
|
|
2450
|
+
import { delimiter, isAbsolute, resolve as resolve3 } from "node:path";
|
|
2451
2451
|
function findAcpExecutable(command) {
|
|
2452
|
-
const candidates =
|
|
2452
|
+
const candidates = isAbsolute(command) ? [command] : (process.env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve3(directory, command));
|
|
2453
2453
|
for (const candidate of candidates) {
|
|
2454
2454
|
try {
|
|
2455
2455
|
accessSync(candidate, constants2.X_OK);
|
|
@@ -2487,12 +2487,12 @@ var init_executable = __esm({
|
|
|
2487
2487
|
// src/integrations/acp/claude-settings.ts
|
|
2488
2488
|
import { createRequire } from "node:module";
|
|
2489
2489
|
import { pathToFileURL } from "node:url";
|
|
2490
|
-
import { basename, join as
|
|
2490
|
+
import { basename, join as join5, resolve as resolve4 } from "node:path";
|
|
2491
2491
|
async function claudeOptions(command, cwd, supplied, includeSkills = true) {
|
|
2492
2492
|
const normalized = supplied?.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
2493
2493
|
const requested = normalized === "extrahigh" ? "xhigh" : normalized;
|
|
2494
2494
|
const script = command.args[0];
|
|
2495
|
-
const anchor = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ?
|
|
2495
|
+
const anchor = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ? resolve4(cwd, script) : command.command;
|
|
2496
2496
|
const require2 = createRequire(pathToFileURL(anchor));
|
|
2497
2497
|
const sdk = await import(pathToFileURL(require2.resolve("@anthropic-ai/claude-agent-sdk")).href);
|
|
2498
2498
|
requireThat(object(sdk) && typeof sdk.resolveSettings === "function", "Claude ACP \u9700\u8981\u63D0\u4F9B resolveSettings \u7684\u539F\u751F SDK\u3002");
|
|
@@ -2507,7 +2507,7 @@ async function claudeOptions(command, cwd, supplied, includeSkills = true) {
|
|
|
2507
2507
|
return {
|
|
2508
2508
|
...thinking ? { thinking } : {},
|
|
2509
2509
|
options: {
|
|
2510
|
-
...includeSkills ? { plugins: [{ type: "local", path:
|
|
2510
|
+
...includeSkills ? { plugins: [{ type: "local", path: join5(resourceRoot, "skills") }] } : {},
|
|
2511
2511
|
...effort ? { effort } : {},
|
|
2512
2512
|
// SDK effort alone loses to CLAUDE_CODE_EFFORT_LEVEL. A flag-tier env entry
|
|
2513
2513
|
// applies the explicit choice to this invocation and preserves other settings.
|
|
@@ -2600,7 +2600,7 @@ var init_claude = __esm({
|
|
|
2600
2600
|
},
|
|
2601
2601
|
async prepareLaunch(context) {
|
|
2602
2602
|
const base = defaultPrepareLaunch(context);
|
|
2603
|
-
const claude = await claudeOptions(base.command, context.
|
|
2603
|
+
const claude = await claudeOptions(base.command, context.workspace, context.options.thinking, context.features?.skills !== false);
|
|
2604
2604
|
return {
|
|
2605
2605
|
...base,
|
|
2606
2606
|
...claude.thinking ? { defaultThinking: claude.thinking } : {},
|
|
@@ -2627,7 +2627,7 @@ var init_claude = __esm({
|
|
|
2627
2627
|
|
|
2628
2628
|
// src/integrations/acp/harnesses/dsh.ts
|
|
2629
2629
|
import { writeFile } from "node:fs/promises";
|
|
2630
|
-
import { join as
|
|
2630
|
+
import { join as join6 } from "node:path";
|
|
2631
2631
|
var dshAcpHarness;
|
|
2632
2632
|
var init_dsh = __esm({
|
|
2633
2633
|
"src/integrations/acp/harnesses/dsh.ts"() {
|
|
@@ -2647,10 +2647,10 @@ var init_dsh = __esm({
|
|
|
2647
2647
|
validateStartOptions: (options) => validateStandardAcpOptions("dsh", options),
|
|
2648
2648
|
async prepareLaunch(context) {
|
|
2649
2649
|
const base = defaultPrepareLaunch(context);
|
|
2650
|
-
const patch =
|
|
2650
|
+
const patch = join6(context.directory, "acp-dsh-patch.json");
|
|
2651
2651
|
await writeFile(
|
|
2652
2652
|
patch,
|
|
2653
|
-
JSON.stringify([{ insert: [{ id: "pbot-acp-member", name:
|
|
2653
|
+
JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join6(context.packageRoot, "lib/extension/hosts/dsh/acp-entry.js") }] }]) + "\n",
|
|
2654
2654
|
{ mode: 384 }
|
|
2655
2655
|
);
|
|
2656
2656
|
return {
|
|
@@ -2673,7 +2673,7 @@ var init_dsh = __esm({
|
|
|
2673
2673
|
});
|
|
2674
2674
|
|
|
2675
2675
|
// src/integrations/acp/harnesses/pi.ts
|
|
2676
|
-
import { join as
|
|
2676
|
+
import { join as join7 } from "node:path";
|
|
2677
2677
|
var piAcpHarness;
|
|
2678
2678
|
var init_pi = __esm({
|
|
2679
2679
|
"src/integrations/acp/harnesses/pi.ts"() {
|
|
@@ -2697,7 +2697,7 @@ var init_pi = __esm({
|
|
|
2697
2697
|
env: {
|
|
2698
2698
|
...base.env,
|
|
2699
2699
|
PBOT_ACP_PI_COMMAND: process.env.PI_ACP_PI_COMMAND ?? acpExecutable("pi", "pi"),
|
|
2700
|
-
PI_ACP_PI_COMMAND:
|
|
2700
|
+
PI_ACP_PI_COMMAND: join7(context.packageRoot, "bin/pbot-pi-acp.mjs")
|
|
2701
2701
|
}
|
|
2702
2702
|
};
|
|
2703
2703
|
},
|
|
@@ -2848,9 +2848,9 @@ var init_launch = __esm({
|
|
|
2848
2848
|
// src/integrations/acp/history-summary.ts
|
|
2849
2849
|
import { fork } from "node:child_process";
|
|
2850
2850
|
import { existsSync } from "node:fs";
|
|
2851
|
-
import { resolve as
|
|
2851
|
+
import { resolve as resolve5 } from "node:path";
|
|
2852
2852
|
function createAcpHistorySummarizer(options) {
|
|
2853
|
-
const workerPath =
|
|
2853
|
+
const workerPath = resolve5(resourceRoot, "../lib/extension/acp-worker.js");
|
|
2854
2854
|
requireThat(process.platform === "linux" || process.platform === "darwin", "ACP \u6458\u8981 worker \u5F53\u524D\u652F\u6301 Linux \u548C macOS\u3002");
|
|
2855
2855
|
requireThat(existsSync(workerPath), "\u7F3A\u5C11 ACP worker \u6784\u5EFA\u4EA7\u7269\uFF1B\u8BF7\u5148\u8FD0\u884C npm run build\u3002");
|
|
2856
2856
|
const commands2 = options.commands ?? {};
|
|
@@ -2941,8 +2941,8 @@ var init_history_summary = __esm({
|
|
|
2941
2941
|
});
|
|
2942
2942
|
|
|
2943
2943
|
// src/storage/file-access.ts
|
|
2944
|
-
import { lstatSync as lstatSync2, mkdirSync as
|
|
2945
|
-
import { join as
|
|
2944
|
+
import { lstatSync as lstatSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
2945
|
+
import { join as join8 } from "node:path";
|
|
2946
2946
|
function fileId(id) {
|
|
2947
2947
|
requireThat(/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(id), "\u5185\u90E8\u8BB0\u5F55 ID \u65E0\u6548\u3002");
|
|
2948
2948
|
return id;
|
|
@@ -2952,9 +2952,9 @@ function privateDirectory(root, relative4) {
|
|
|
2952
2952
|
let parent = root;
|
|
2953
2953
|
for (const part of parts) {
|
|
2954
2954
|
fileId(part);
|
|
2955
|
-
const path =
|
|
2955
|
+
const path = join8(parent, part);
|
|
2956
2956
|
try {
|
|
2957
|
-
|
|
2957
|
+
mkdirSync2(path, { mode: 448 });
|
|
2958
2958
|
syncDirectory(parent);
|
|
2959
2959
|
} catch (error) {
|
|
2960
2960
|
if (error.code !== "EEXIST") throw error;
|
|
@@ -3047,8 +3047,8 @@ var init_history_format = __esm({
|
|
|
3047
3047
|
|
|
3048
3048
|
// src/storage/history-files.ts
|
|
3049
3049
|
import { spawnSync } from "node:child_process";
|
|
3050
|
-
import { linkSync as linkSync2, lstatSync as lstatSync3, mkdirSync as
|
|
3051
|
-
import { basename as basename2, dirname as dirname5, join as
|
|
3050
|
+
import { linkSync as linkSync2, lstatSync as lstatSync3, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync4, realpathSync as realpathSync3, rmdirSync as rmdirSync2, unlinkSync as unlinkSync2 } from "node:fs";
|
|
3051
|
+
import { basename as basename2, dirname as dirname5, join as join9, relative as relative2, resolve as resolve6 } from "node:path";
|
|
3052
3052
|
import { isDeepStrictEqual } from "node:util";
|
|
3053
3053
|
function ordinaryDirectory(path) {
|
|
3054
3054
|
const stat7 = lstatSync3(path, { throwIfNoEntry: false });
|
|
@@ -3066,11 +3066,11 @@ function sharedDirectory(path) {
|
|
|
3066
3066
|
}
|
|
3067
3067
|
function ensureDirectory(path) {
|
|
3068
3068
|
if (sharedDirectory(path)) return;
|
|
3069
|
-
const first =
|
|
3069
|
+
const first = mkdirSync3(path, { recursive: true, mode: 448 });
|
|
3070
3070
|
requireThat(sharedDirectory(path), "\u65E0\u6CD5\u521B\u5EFA\u5386\u53F2\u76EE\u5F55\uFF1A" + path);
|
|
3071
3071
|
if (first) {
|
|
3072
|
-
const existing = dirname5(
|
|
3073
|
-
for (let child =
|
|
3072
|
+
const existing = dirname5(resolve6(first));
|
|
3073
|
+
for (let child = resolve6(path); child !== existing && child !== dirname5(child); child = dirname5(child)) {
|
|
3074
3074
|
syncDirectory(realpathSync3(dirname5(child)));
|
|
3075
3075
|
}
|
|
3076
3076
|
}
|
|
@@ -3114,14 +3114,14 @@ function summaryArtifactBucket(artifact) {
|
|
|
3114
3114
|
function bucketDirs(directory, depth) {
|
|
3115
3115
|
if (!ordinaryDirectory(directory)) return [];
|
|
3116
3116
|
const buckets = [];
|
|
3117
|
-
const entries =
|
|
3117
|
+
const entries = readdirSync(directory, { withFileTypes: true });
|
|
3118
3118
|
const years = entries.filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && yearPattern.test(entry.name)).map((entry) => entry.name).sort((a, b) => b.localeCompare(a));
|
|
3119
3119
|
if (depth === "year") {
|
|
3120
3120
|
buckets.push(...years);
|
|
3121
3121
|
} else {
|
|
3122
3122
|
for (const year of years) {
|
|
3123
|
-
const yearDir =
|
|
3124
|
-
const months =
|
|
3123
|
+
const yearDir = join9(directory, year);
|
|
3124
|
+
const months = readdirSync(yearDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && monthPattern.test(entry.name)).map((entry) => entry.name).sort((a, b) => b.localeCompare(a));
|
|
3125
3125
|
for (const month of months) buckets.push(`${year}/${month}`);
|
|
3126
3126
|
}
|
|
3127
3127
|
}
|
|
@@ -3135,7 +3135,7 @@ function listLayoutJsonFiles(directory, layout, depth = "month") {
|
|
|
3135
3135
|
if (layout === "flat") return topLevelJsonNames(directory);
|
|
3136
3136
|
const results = [];
|
|
3137
3137
|
for (const bucket of bucketDirs(directory, depth)) {
|
|
3138
|
-
const dir =
|
|
3138
|
+
const dir = join9(directory, bucket);
|
|
3139
3139
|
for (const name of topLevelJsonNames(dir)) {
|
|
3140
3140
|
results.push(`${bucket}/${name}`);
|
|
3141
3141
|
}
|
|
@@ -3145,10 +3145,10 @@ function listLayoutJsonFiles(directory, layout, depth = "month") {
|
|
|
3145
3145
|
function locateLayoutFile(directory, name, layout, depth = "month") {
|
|
3146
3146
|
if (!ordinaryDirectory(directory)) return void 0;
|
|
3147
3147
|
if (layout === "flat") {
|
|
3148
|
-
return ordinaryFile(
|
|
3148
|
+
return ordinaryFile(join9(directory, name)) ? name : void 0;
|
|
3149
3149
|
}
|
|
3150
3150
|
for (const bucket of bucketDirs(directory, depth)) {
|
|
3151
|
-
if (ordinaryFile(
|
|
3151
|
+
if (ordinaryFile(join9(directory, bucket, name))) return `${bucket}/${name}`;
|
|
3152
3152
|
}
|
|
3153
3153
|
return void 0;
|
|
3154
3154
|
}
|
|
@@ -3199,7 +3199,7 @@ function findCandidateJsonFiles(directory, query, layout = "monthly", depth = "m
|
|
|
3199
3199
|
for (const line of result.stdout.split(/\r?\n/)) {
|
|
3200
3200
|
const trimmedLine = line.trim();
|
|
3201
3201
|
if (!trimmedLine) continue;
|
|
3202
|
-
const rel = relative2(base,
|
|
3202
|
+
const rel = relative2(base, resolve6(trimmedLine)).replaceAll("\\", "/");
|
|
3203
3203
|
if (layout === "flat") {
|
|
3204
3204
|
if (!rel.includes("/") && rel.endsWith(".json")) matched2.push(rel);
|
|
3205
3205
|
} else if (relativePattern.test(rel)) {
|
|
@@ -3213,7 +3213,7 @@ function findCandidateJsonFiles(directory, query, layout = "monthly", depth = "m
|
|
|
3213
3213
|
const matched = [];
|
|
3214
3214
|
for (const rel of listLayoutJsonFiles(directory, layout, depth)) {
|
|
3215
3215
|
try {
|
|
3216
|
-
const content =
|
|
3216
|
+
const content = readFileSync4(join9(directory, rel), "utf8");
|
|
3217
3217
|
if (content.toLowerCase().includes(needle)) matched.push(rel);
|
|
3218
3218
|
} catch {
|
|
3219
3219
|
}
|
|
@@ -3234,7 +3234,7 @@ var init_history_files = __esm({
|
|
|
3234
3234
|
monthlyRelativeJsonPattern = /^(?:\d{4}\/(?:0[1-9]|1[0-2])|unknown)\/[^/]+\.json$/;
|
|
3235
3235
|
yearlyRelativeJsonPattern = /^(?:\d{4}|unknown)\/[^/]+\.json$/;
|
|
3236
3236
|
unknownHistoryBucket = "unknown";
|
|
3237
|
-
topLevelJsonNames = (directory) =>
|
|
3237
|
+
topLevelJsonNames = (directory) => readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isFile() && !entry.isSymbolicLink() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
|
|
3238
3238
|
filename = (id) => fileId(id) + ".json";
|
|
3239
3239
|
diagnostic = (path, error) => path + ": " + String(error);
|
|
3240
3240
|
HistoryFiles = class {
|
|
@@ -3253,20 +3253,20 @@ var init_history_files = __esm({
|
|
|
3253
3253
|
return this.#rawWarnings;
|
|
3254
3254
|
}
|
|
3255
3255
|
get rawDirectory() {
|
|
3256
|
-
return
|
|
3256
|
+
return join9(this.directory, "raw");
|
|
3257
3257
|
}
|
|
3258
3258
|
get summariesDirectory() {
|
|
3259
|
-
return
|
|
3259
|
+
return join9(this.directory, "summaries");
|
|
3260
3260
|
}
|
|
3261
3261
|
summaryDirectory(dimension) {
|
|
3262
3262
|
requireThat(isHistoryIdentifier(dimension), "\u5386\u53F2\u6458\u8981\u7EF4\u5EA6\u65E0\u6548\uFF1A" + dimension);
|
|
3263
|
-
return
|
|
3263
|
+
return join9(this.summariesDirectory, dimension);
|
|
3264
3264
|
}
|
|
3265
3265
|
withLock(lockName, label, operation) {
|
|
3266
3266
|
ensureDirectory(this.directory);
|
|
3267
|
-
const lock =
|
|
3267
|
+
const lock = join9(this.directory, lockName);
|
|
3268
3268
|
try {
|
|
3269
|
-
|
|
3269
|
+
mkdirSync3(lock, { mode: 448 });
|
|
3270
3270
|
} catch (error) {
|
|
3271
3271
|
if (error.code === "EEXIST") {
|
|
3272
3272
|
throw Object.assign(new Error("\u5386\u53F2\u5199\u9501\u88AB\u5360\u7528\uFF1A" + label), { code: "PBOT_HISTORY_BUSY" });
|
|
@@ -3310,7 +3310,7 @@ var init_history_files = __esm({
|
|
|
3310
3310
|
rawCount,
|
|
3311
3311
|
summaryCount,
|
|
3312
3312
|
total,
|
|
3313
|
-
message: `\
|
|
3313
|
+
message: `\u5F53\u524D\u6309\u5E74\u6708\u8BFB\u53D6\u5386\u53F2\uFF0C\u5E73\u94FA\u76EE\u5F55\u4E2D\u7684 ${rawCount} \u4EFD\u539F\u6587\u548C ${summaryCount} \u4EFD\u6458\u8981\u5C1A\u672A\u7EB3\u5165\u68C0\u7D22\u3002\u53EF\u5728\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7528 pbot history migrate --dry-run \u9884\u89C8\uFF0C\u7528 pbot history migrate \u6267\u884C\uFF08Pi\u3001dsh \u53EF\u7528 /pbot history migrate\uFF09\u3002\u8981\u7EE7\u7EED\u4F7F\u7528\u5E73\u94FA\u76EE\u5F55\uFF0C\u53EF\u5728 .pbot/config.json \u4E2D\u8BBE\u7F6E "history": { "layout": "flat" }\u3002`
|
|
3314
3314
|
};
|
|
3315
3315
|
}
|
|
3316
3316
|
listFlatRawFiles() {
|
|
@@ -3360,7 +3360,7 @@ var init_history_files = __esm({
|
|
|
3360
3360
|
const files = onlyFiles ?? listLayoutJsonFiles(this.rawDirectory, this.layout);
|
|
3361
3361
|
const results = [];
|
|
3362
3362
|
for (const rel of files) {
|
|
3363
|
-
const path =
|
|
3363
|
+
const path = join9(this.rawDirectory, rel);
|
|
3364
3364
|
try {
|
|
3365
3365
|
const raw = readJsonFile(this.directory, "raw/" + rel, (value) => namedRaw(value, rel));
|
|
3366
3366
|
if (filterHost !== void 0 && raw.host !== filterHost) continue;
|
|
@@ -3401,7 +3401,7 @@ var init_history_files = __esm({
|
|
|
3401
3401
|
}
|
|
3402
3402
|
listDimensions() {
|
|
3403
3403
|
if (!sharedDirectory(this.directory) || !ordinaryDirectory(this.summariesDirectory)) return [];
|
|
3404
|
-
const entries =
|
|
3404
|
+
const entries = readdirSync(this.summariesDirectory, { withFileTypes: true });
|
|
3405
3405
|
return entries.filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && isHistoryIdentifier(entry.name)).map((entry) => entry.name).sort();
|
|
3406
3406
|
}
|
|
3407
3407
|
summaryBucketDepth(dimension) {
|
|
@@ -3414,7 +3414,7 @@ var init_history_files = __esm({
|
|
|
3414
3414
|
const files = onlyFiles ?? listLayoutJsonFiles(dir, this.layout, this.summaryBucketDepth(dimension));
|
|
3415
3415
|
const results = [];
|
|
3416
3416
|
for (const rel of files) {
|
|
3417
|
-
const path =
|
|
3417
|
+
const path = join9(dir, rel);
|
|
3418
3418
|
try {
|
|
3419
3419
|
results.push(readJsonFile(this.directory, `summaries/${dimension}/${rel}`, (value) => namedSummary(value, rel, dimension)));
|
|
3420
3420
|
} catch (error) {
|
|
@@ -3467,9 +3467,9 @@ var init_history_files = __esm({
|
|
|
3467
3467
|
});
|
|
3468
3468
|
|
|
3469
3469
|
// src/services/history/workspace-history.ts
|
|
3470
|
-
import { join as
|
|
3470
|
+
import { join as join10 } from "node:path";
|
|
3471
3471
|
function workspaceHistoryFiles(root, host) {
|
|
3472
|
-
return new HistoryFiles(
|
|
3472
|
+
return new HistoryFiles(join10(root, ".pbot/history"), host, readWorkspaceHistoryLayoutSync(root));
|
|
3473
3473
|
}
|
|
3474
3474
|
var init_workspace_history = __esm({
|
|
3475
3475
|
"src/services/history/workspace-history.ts"() {
|
|
@@ -3480,7 +3480,7 @@ var init_workspace_history = __esm({
|
|
|
3480
3480
|
});
|
|
3481
3481
|
|
|
3482
3482
|
// src/services/history/history-migrate.ts
|
|
3483
|
-
import { join as
|
|
3483
|
+
import { join as join11 } from "node:path";
|
|
3484
3484
|
function migrateWorkspaceHistory(root, options = {}) {
|
|
3485
3485
|
const files = workspaceHistoryFiles(root);
|
|
3486
3486
|
const { layout } = files;
|
|
@@ -3506,7 +3506,7 @@ function migrateWorkspaceHistory(root, options = {}) {
|
|
|
3506
3506
|
moved.push({ ...source, id: record.id, from, to });
|
|
3507
3507
|
}
|
|
3508
3508
|
} catch (error) {
|
|
3509
|
-
errors.push({ path:
|
|
3509
|
+
errors.push({ path: join11(files.directory, from), error: error instanceof Error ? error.message : String(error) });
|
|
3510
3510
|
}
|
|
3511
3511
|
}
|
|
3512
3512
|
const run = () => {
|
|
@@ -3529,15 +3529,15 @@ var init_history_migrate = __esm({
|
|
|
3529
3529
|
});
|
|
3530
3530
|
|
|
3531
3531
|
// src/services/history/summary-dimensions/monthly.ts
|
|
3532
|
-
import { createHash
|
|
3533
|
-
import { readFileSync as
|
|
3534
|
-
import { join as
|
|
3532
|
+
import { createHash } from "node:crypto";
|
|
3533
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
3534
|
+
import { join as join12 } from "node:path";
|
|
3535
3535
|
function systemPrompt() {
|
|
3536
|
-
cachedPrompt ??=
|
|
3536
|
+
cachedPrompt ??= readFileSync5(join12(resourceRoot, "prompts/history-monthly-summary.md"), "utf8");
|
|
3537
3537
|
return cachedPrompt;
|
|
3538
3538
|
}
|
|
3539
3539
|
function fingerprintSessionSummaries(summaries) {
|
|
3540
|
-
const hash =
|
|
3540
|
+
const hash = createHash("sha256");
|
|
3541
3541
|
for (const item of summaries) {
|
|
3542
3542
|
hash.update(JSON.stringify([item.id, item.title, item.from, item.to, item.source.fingerprint, item.text]));
|
|
3543
3543
|
hash.update("\n");
|
|
@@ -3571,7 +3571,7 @@ var init_monthly = __esm({
|
|
|
3571
3571
|
monthlySummaryDimension = {
|
|
3572
3572
|
id: "monthly",
|
|
3573
3573
|
title: "\u6708\u5EA6\u5386\u53F2\u6C47\u603B",
|
|
3574
|
-
description: "\u6309\
|
|
3574
|
+
description: "\u6309\u4F1A\u8BDD\u5F00\u59CB\u7684 UTC \u6708\u4EFD\u6C47\u603B\u4F1A\u8BDD\u6458\u8981\uFF0C\u53EF\u4ECE\u6708\u5EA6\u7ED3\u679C\u67E5\u56DE\u5404\u4F1A\u8BDD\u3002",
|
|
3575
3575
|
requiresMonthlyLayout: true,
|
|
3576
3576
|
plan(_raws, existing, options = {}) {
|
|
3577
3577
|
const force = Boolean(options.force);
|
|
@@ -3644,7 +3644,7 @@ var init_monthly = __esm({
|
|
|
3644
3644
|
});
|
|
3645
3645
|
|
|
3646
3646
|
// src/services/history/history-index.ts
|
|
3647
|
-
import { createHash as
|
|
3647
|
+
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
3648
3648
|
function mergeBranches(previous, observed, removed) {
|
|
3649
3649
|
const parents = /* @__PURE__ */ new Map();
|
|
3650
3650
|
for (const branch of [...previous, ...observed]) {
|
|
@@ -3736,7 +3736,7 @@ function rawSessionSpan(exchanges) {
|
|
|
3736
3736
|
};
|
|
3737
3737
|
}
|
|
3738
3738
|
function fingerprintExchanges(exchanges) {
|
|
3739
|
-
const hash =
|
|
3739
|
+
const hash = createHash2("sha256");
|
|
3740
3740
|
for (const item of exchanges) {
|
|
3741
3741
|
hash.update(JSON.stringify([item.id, item.entryIds, item.text, item.from, item.to, item.completed]));
|
|
3742
3742
|
hash.update("\n");
|
|
@@ -3751,10 +3751,10 @@ var init_history_index = __esm({
|
|
|
3751
3751
|
});
|
|
3752
3752
|
|
|
3753
3753
|
// src/services/history/summary-dimensions/session.ts
|
|
3754
|
-
import { readFileSync as
|
|
3755
|
-
import { join as
|
|
3754
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
3755
|
+
import { join as join13 } from "node:path";
|
|
3756
3756
|
function systemPrompt2() {
|
|
3757
|
-
cachedPrompt2 ??=
|
|
3757
|
+
cachedPrompt2 ??= readFileSync6(join13(resourceRoot, "prompts/history-summary.md"), "utf8");
|
|
3758
3758
|
return cachedPrompt2;
|
|
3759
3759
|
}
|
|
3760
3760
|
function formatExchanges(exchanges) {
|
|
@@ -3780,7 +3780,7 @@ var init_session = __esm({
|
|
|
3780
3780
|
sessionSummaryDimension = {
|
|
3781
3781
|
id: "session",
|
|
3782
3782
|
title: "\u4F1A\u8BDD\u4EFB\u52A1\u6458\u8981",
|
|
3783
|
-
description: "\
|
|
3783
|
+
description: "\u6C47\u603B\u5355\u6B21\u4F1A\u8BDD\u7684\u76EE\u6807\u3001\u51B3\u5B9A\u3001\u7ED3\u679C\u548C\u672A\u51B3\u4E8B\u9879\u3002",
|
|
3784
3784
|
plan(raws, existing, options = {}) {
|
|
3785
3785
|
const force = Boolean(options.force);
|
|
3786
3786
|
const tasks = [];
|
|
@@ -3841,10 +3841,13 @@ var init_session = __esm({
|
|
|
3841
3841
|
`\u3010\u5DF2\u6709\u6458\u8981\uFF08${task.existing.from} \u2014 ${task.existing.to}\uFF09\u3011
|
|
3842
3842
|
${task.existing.text}`,
|
|
3843
3843
|
`\u3010\u65B0\u589E\u5BF9\u8BDD\u3011
|
|
3844
|
-
${formatExchanges(task.addedExchanges)}
|
|
3845
|
-
"\u5728\u5DF2\u6709\u6458\u8981\u57FA\u7840\u4E0A\u5408\u5E76\u65B0\u589E\u5BF9\u8BDD\uFF0C\u8F93\u51FA\u66F4\u65B0\u540E\u7684\u5B8C\u6574\u6458\u8981\uFF1A\u4FDD\u7559\u4ECD\u6709\u6548\u7684\u4E8B\u5B9E\uFF0C\u7528\u65B0\u51B3\u5B9A\u8986\u76D6\u65E7\u51B3\u5B9A\uFF0C\u53BB\u91CD\u5E76\u4FDD\u6301\u7B80\u6D01\u3002"
|
|
3844
|
+
${formatExchanges(task.addedExchanges)}`
|
|
3846
3845
|
].join("\n\n");
|
|
3847
|
-
return {
|
|
3846
|
+
return {
|
|
3847
|
+
system: system + "\n\u5408\u5E76\u5DF2\u6709\u6458\u8981\u4E0E\u65B0\u589E\u5BF9\u8BDD\uFF0C\u8F93\u51FA\u5B8C\u6574\u6458\u8981\u3002\u4FDD\u7559\u4ECD\u6709\u6548\u7684\u4E8B\u5B9E\uFF0C\u7528\u540E\u7EED\u660E\u786E\u7684\u51B3\u5B9A\u66F4\u65B0\u76F8\u5E94\u7ED3\u8BBA\u3002",
|
|
3848
|
+
prompt: prompt2,
|
|
3849
|
+
maxTokens: 2048
|
|
3850
|
+
};
|
|
3848
3851
|
}
|
|
3849
3852
|
const prompt = [
|
|
3850
3853
|
...heading,
|
|
@@ -3956,7 +3959,8 @@ function evaluateSummaryReminder(raws, allSummaries, pendingCount, options = {})
|
|
|
3956
3959
|
if (latestSummaryMs !== void 0 && nowMs - latestSummaryMs < thresholdMs) return void 0;
|
|
3957
3960
|
const rawAgeDays = Math.floor((nowMs - oldestRawMs) / dayMs);
|
|
3958
3961
|
const daysSinceLastSummary = latestSummaryMs === void 0 ? void 0 : Math.floor((nowMs - latestSummaryMs) / dayMs);
|
|
3959
|
-
const
|
|
3962
|
+
const lastUpdate = daysSinceLastSummary === void 0 ? "\u5C1A\u65E0\u6458\u8981" : `\u4E0A\u6B21\u66F4\u65B0\u6458\u8981\u5728 ${daysSinceLastSummary} \u5929\u524D`;
|
|
3963
|
+
const message = `\u5DE5\u4F5C\u533A\u5DF2\u79EF\u7D2F ${rawAgeDays} \u5929\u7684\u5386\u53F2\uFF0C${lastUpdate}\uFF0C${pendingCount} \u9879\u5F85\u6458\u8981\u3002\u53EF\u5728\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u8FD0\u884C pbot history summary\uFF0C\u6216\u5728 Pi\u3001dsh \u4F1A\u8BDD\u4E2D\u8F93\u5165 /pbot history summary\u3002`;
|
|
3960
3964
|
return {
|
|
3961
3965
|
rawCount: raws.length,
|
|
3962
3966
|
pendingCount,
|
|
@@ -13446,13 +13450,13 @@ var require_boolSchema = __commonJS({
|
|
|
13446
13450
|
}
|
|
13447
13451
|
}
|
|
13448
13452
|
exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
13449
|
-
function boolOrEmptySchema(it,
|
|
13453
|
+
function boolOrEmptySchema(it, valid15) {
|
|
13450
13454
|
const { gen, schema: schema2 } = it;
|
|
13451
13455
|
if (schema2 === false) {
|
|
13452
|
-
gen.var(
|
|
13456
|
+
gen.var(valid15, false);
|
|
13453
13457
|
falseSchemaError(it);
|
|
13454
13458
|
} else {
|
|
13455
|
-
gen.var(
|
|
13459
|
+
gen.var(valid15, true);
|
|
13456
13460
|
}
|
|
13457
13461
|
}
|
|
13458
13462
|
exports.boolOrEmptySchema = boolOrEmptySchema;
|
|
@@ -13833,15 +13837,15 @@ var require_code2 = __commonJS({
|
|
|
13833
13837
|
exports.usePattern = usePattern;
|
|
13834
13838
|
function validateArray(cxt) {
|
|
13835
13839
|
const { gen, data, keyword, it } = cxt;
|
|
13836
|
-
const
|
|
13840
|
+
const valid15 = gen.name("valid");
|
|
13837
13841
|
if (it.allErrors) {
|
|
13838
13842
|
const validArr = gen.let("valid", true);
|
|
13839
13843
|
validateItems(() => gen.assign(validArr, false));
|
|
13840
13844
|
return validArr;
|
|
13841
13845
|
}
|
|
13842
|
-
gen.var(
|
|
13846
|
+
gen.var(valid15, true);
|
|
13843
13847
|
validateItems(() => gen.break());
|
|
13844
|
-
return
|
|
13848
|
+
return valid15;
|
|
13845
13849
|
function validateItems(notValid) {
|
|
13846
13850
|
const len = gen.const("len", (0, codegen_1._)`${data}.length`);
|
|
13847
13851
|
gen.forRange("i", 0, len, (i) => {
|
|
@@ -13849,8 +13853,8 @@ var require_code2 = __commonJS({
|
|
|
13849
13853
|
keyword,
|
|
13850
13854
|
dataProp: i,
|
|
13851
13855
|
dataPropType: util_1.Type.Num
|
|
13852
|
-
},
|
|
13853
|
-
gen.if((0, codegen_1.not)(
|
|
13856
|
+
}, valid15);
|
|
13857
|
+
gen.if((0, codegen_1.not)(valid15), notValid);
|
|
13854
13858
|
});
|
|
13855
13859
|
}
|
|
13856
13860
|
}
|
|
@@ -13862,7 +13866,7 @@ var require_code2 = __commonJS({
|
|
|
13862
13866
|
const alwaysValid = schema2.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
|
|
13863
13867
|
if (alwaysValid && !it.opts.unevaluated)
|
|
13864
13868
|
return;
|
|
13865
|
-
const
|
|
13869
|
+
const valid15 = gen.let("valid", false);
|
|
13866
13870
|
const schValid = gen.name("_valid");
|
|
13867
13871
|
gen.block(() => schema2.forEach((_sch, i) => {
|
|
13868
13872
|
const schCxt = cxt.subschema({
|
|
@@ -13870,12 +13874,12 @@ var require_code2 = __commonJS({
|
|
|
13870
13874
|
schemaProp: i,
|
|
13871
13875
|
compositeRule: true
|
|
13872
13876
|
}, schValid);
|
|
13873
|
-
gen.assign(
|
|
13877
|
+
gen.assign(valid15, (0, codegen_1._)`${valid15} || ${schValid}`);
|
|
13874
13878
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
13875
13879
|
if (!merged)
|
|
13876
|
-
gen.if((0, codegen_1.not)(
|
|
13880
|
+
gen.if((0, codegen_1.not)(valid15));
|
|
13877
13881
|
}));
|
|
13878
|
-
cxt.result(
|
|
13882
|
+
cxt.result(valid15, () => cxt.reset(), () => cxt.error(true));
|
|
13879
13883
|
}
|
|
13880
13884
|
exports.validateUnion = validateUnion;
|
|
13881
13885
|
}
|
|
@@ -13897,15 +13901,15 @@ var require_keyword = __commonJS({
|
|
|
13897
13901
|
const schemaRef = useKeyword(gen, keyword, macroSchema);
|
|
13898
13902
|
if (it.opts.validateSchema !== false)
|
|
13899
13903
|
it.self.validateSchema(macroSchema, true);
|
|
13900
|
-
const
|
|
13904
|
+
const valid15 = gen.name("valid");
|
|
13901
13905
|
cxt.subschema({
|
|
13902
13906
|
schema: macroSchema,
|
|
13903
13907
|
schemaPath: codegen_1.nil,
|
|
13904
13908
|
errSchemaPath: `${it.errSchemaPath}/${keyword}`,
|
|
13905
13909
|
topSchemaRef: schemaRef,
|
|
13906
13910
|
compositeRule: true
|
|
13907
|
-
},
|
|
13908
|
-
cxt.pass(
|
|
13911
|
+
}, valid15);
|
|
13912
|
+
cxt.pass(valid15, () => cxt.error(true));
|
|
13909
13913
|
}
|
|
13910
13914
|
exports.macroKeywordCode = macroKeywordCode;
|
|
13911
13915
|
function funcKeywordCode(cxt, def) {
|
|
@@ -13914,9 +13918,9 @@ var require_keyword = __commonJS({
|
|
|
13914
13918
|
checkAsyncKeyword(it, def);
|
|
13915
13919
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema2, parentSchema, it) : def.validate;
|
|
13916
13920
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
13917
|
-
const
|
|
13918
|
-
cxt.block$data(
|
|
13919
|
-
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a :
|
|
13921
|
+
const valid15 = gen.let("valid");
|
|
13922
|
+
cxt.block$data(valid15, validateKeyword);
|
|
13923
|
+
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid15);
|
|
13920
13924
|
function validateKeyword() {
|
|
13921
13925
|
if (def.errors === false) {
|
|
13922
13926
|
assignValid();
|
|
@@ -13932,7 +13936,7 @@ var require_keyword = __commonJS({
|
|
|
13932
13936
|
}
|
|
13933
13937
|
function validateAsync() {
|
|
13934
13938
|
const ruleErrs = gen.let("ruleErrs", null);
|
|
13935
|
-
gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(
|
|
13939
|
+
gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(valid15, false).if((0, codegen_1._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._)`${e}.errors`), () => gen.throw(e)));
|
|
13936
13940
|
return ruleErrs;
|
|
13937
13941
|
}
|
|
13938
13942
|
function validateSync() {
|
|
@@ -13944,11 +13948,11 @@ var require_keyword = __commonJS({
|
|
|
13944
13948
|
function assignValid(_await = def.async ? (0, codegen_1._)`await ` : codegen_1.nil) {
|
|
13945
13949
|
const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self;
|
|
13946
13950
|
const passSchema = !("compile" in def && !$data || def.schema === false);
|
|
13947
|
-
gen.assign(
|
|
13951
|
+
gen.assign(valid15, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
13948
13952
|
}
|
|
13949
13953
|
function reportErrs(errors) {
|
|
13950
13954
|
var _a2;
|
|
13951
|
-
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 :
|
|
13955
|
+
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid15), errors);
|
|
13952
13956
|
}
|
|
13953
13957
|
}
|
|
13954
13958
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -13985,8 +13989,8 @@ var require_keyword = __commonJS({
|
|
|
13985
13989
|
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
|
|
13986
13990
|
}
|
|
13987
13991
|
if (def.validateSchema) {
|
|
13988
|
-
const
|
|
13989
|
-
if (!
|
|
13992
|
+
const valid15 = def.validateSchema(schema2[keyword]);
|
|
13993
|
+
if (!valid15) {
|
|
13990
13994
|
const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def.validateSchema.errors);
|
|
13991
13995
|
if (opts.validateSchema === "log")
|
|
13992
13996
|
self.logger.error(msg);
|
|
@@ -14446,15 +14450,15 @@ var require_validate = __commonJS({
|
|
|
14446
14450
|
const schId = typeof schema2 == "object" && schema2[opts.schemaId];
|
|
14447
14451
|
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
|
|
14448
14452
|
}
|
|
14449
|
-
function subschemaCode(it,
|
|
14453
|
+
function subschemaCode(it, valid15) {
|
|
14450
14454
|
if (isSchemaObj(it)) {
|
|
14451
14455
|
checkKeywords(it);
|
|
14452
14456
|
if (schemaCxtHasRules(it)) {
|
|
14453
|
-
subSchemaObjCode(it,
|
|
14457
|
+
subSchemaObjCode(it, valid15);
|
|
14454
14458
|
return;
|
|
14455
14459
|
}
|
|
14456
14460
|
}
|
|
14457
|
-
(0, boolSchema_1.boolOrEmptySchema)(it,
|
|
14461
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid15);
|
|
14458
14462
|
}
|
|
14459
14463
|
function schemaCxtHasRules({ schema: schema2, self }) {
|
|
14460
14464
|
if (typeof schema2 == "boolean")
|
|
@@ -14467,7 +14471,7 @@ var require_validate = __commonJS({
|
|
|
14467
14471
|
function isSchemaObj(it) {
|
|
14468
14472
|
return typeof it.schema != "boolean";
|
|
14469
14473
|
}
|
|
14470
|
-
function subSchemaObjCode(it,
|
|
14474
|
+
function subSchemaObjCode(it, valid15) {
|
|
14471
14475
|
const { schema: schema2, gen, opts } = it;
|
|
14472
14476
|
if (opts.$comment && schema2.$comment)
|
|
14473
14477
|
commentKeyword(it);
|
|
@@ -14475,7 +14479,7 @@ var require_validate = __commonJS({
|
|
|
14475
14479
|
checkAsyncSchema(it);
|
|
14476
14480
|
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
14477
14481
|
typeAndKeywords(it, errsCount);
|
|
14478
|
-
gen.var(
|
|
14482
|
+
gen.var(valid15, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
14479
14483
|
}
|
|
14480
14484
|
function checkKeywords(it) {
|
|
14481
14485
|
(0, util_1.checkUnknownRules)(it);
|
|
@@ -14742,24 +14746,24 @@ var require_validate = __commonJS({
|
|
|
14742
14746
|
else
|
|
14743
14747
|
this.params = obj;
|
|
14744
14748
|
}
|
|
14745
|
-
block$data(
|
|
14749
|
+
block$data(valid15, codeBlock, $dataValid = codegen_1.nil) {
|
|
14746
14750
|
this.gen.block(() => {
|
|
14747
|
-
this.check$data(
|
|
14751
|
+
this.check$data(valid15, $dataValid);
|
|
14748
14752
|
codeBlock();
|
|
14749
14753
|
});
|
|
14750
14754
|
}
|
|
14751
|
-
check$data(
|
|
14755
|
+
check$data(valid15 = codegen_1.nil, $dataValid = codegen_1.nil) {
|
|
14752
14756
|
if (!this.$data)
|
|
14753
14757
|
return;
|
|
14754
14758
|
const { gen, schemaCode, schemaType, def } = this;
|
|
14755
14759
|
gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid));
|
|
14756
|
-
if (
|
|
14757
|
-
gen.assign(
|
|
14760
|
+
if (valid15 !== codegen_1.nil)
|
|
14761
|
+
gen.assign(valid15, true);
|
|
14758
14762
|
if (schemaType.length || def.validateSchema) {
|
|
14759
14763
|
gen.elseIf(this.invalid$data());
|
|
14760
14764
|
this.$dataError();
|
|
14761
|
-
if (
|
|
14762
|
-
gen.assign(
|
|
14765
|
+
if (valid15 !== codegen_1.nil)
|
|
14766
|
+
gen.assign(valid15, false);
|
|
14763
14767
|
}
|
|
14764
14768
|
gen.else();
|
|
14765
14769
|
}
|
|
@@ -14783,12 +14787,12 @@ var require_validate = __commonJS({
|
|
|
14783
14787
|
return codegen_1.nil;
|
|
14784
14788
|
}
|
|
14785
14789
|
}
|
|
14786
|
-
subschema(appl,
|
|
14790
|
+
subschema(appl, valid15) {
|
|
14787
14791
|
const subschema = (0, subschema_1.getSubschema)(this.it, appl);
|
|
14788
14792
|
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
|
|
14789
14793
|
(0, subschema_1.extendSubschemaMode)(subschema, appl);
|
|
14790
14794
|
const nextContext = { ...this.it, ...subschema, items: void 0, props: void 0 };
|
|
14791
|
-
subschemaCode(nextContext,
|
|
14795
|
+
subschemaCode(nextContext, valid15);
|
|
14792
14796
|
return nextContext;
|
|
14793
14797
|
}
|
|
14794
14798
|
mergeEvaluated(schemaCxt, toName) {
|
|
@@ -14802,10 +14806,10 @@ var require_validate = __commonJS({
|
|
|
14802
14806
|
it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
14803
14807
|
}
|
|
14804
14808
|
}
|
|
14805
|
-
mergeValidEvaluated(schemaCxt,
|
|
14809
|
+
mergeValidEvaluated(schemaCxt, valid15) {
|
|
14806
14810
|
const { it, gen } = this;
|
|
14807
14811
|
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
14808
|
-
gen.if(
|
|
14812
|
+
gen.if(valid15, () => this.mergeEvaluated(schemaCxt, codegen_1.Name));
|
|
14809
14813
|
return true;
|
|
14810
14814
|
}
|
|
14811
14815
|
}
|
|
@@ -15026,7 +15030,7 @@ var require_compile = __commonJS({
|
|
|
15026
15030
|
const schOrFunc = root.refs[ref];
|
|
15027
15031
|
if (schOrFunc)
|
|
15028
15032
|
return schOrFunc;
|
|
15029
|
-
let _sch =
|
|
15033
|
+
let _sch = resolve10.call(this, root, ref);
|
|
15030
15034
|
if (_sch === void 0) {
|
|
15031
15035
|
const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
15032
15036
|
const { schemaId } = this.opts;
|
|
@@ -15053,7 +15057,7 @@ var require_compile = __commonJS({
|
|
|
15053
15057
|
function sameSchemaEnv(s1, s2) {
|
|
15054
15058
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
15055
15059
|
}
|
|
15056
|
-
function
|
|
15060
|
+
function resolve10(root, ref) {
|
|
15057
15061
|
let sch;
|
|
15058
15062
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
15059
15063
|
ref = sch;
|
|
@@ -15917,7 +15921,7 @@ var require_fast_uri = __commonJS({
|
|
|
15917
15921
|
}
|
|
15918
15922
|
return uri;
|
|
15919
15923
|
}
|
|
15920
|
-
function
|
|
15924
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
15921
15925
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
15922
15926
|
const {
|
|
15923
15927
|
parsed: baseParsed,
|
|
@@ -16308,7 +16312,7 @@ var require_fast_uri = __commonJS({
|
|
|
16308
16312
|
var fastUri = {
|
|
16309
16313
|
SCHEMES,
|
|
16310
16314
|
normalize,
|
|
16311
|
-
resolve:
|
|
16315
|
+
resolve: resolve10,
|
|
16312
16316
|
resolveComponent,
|
|
16313
16317
|
equal,
|
|
16314
16318
|
serialize,
|
|
@@ -16495,10 +16499,10 @@ var require_core = __commonJS({
|
|
|
16495
16499
|
} else {
|
|
16496
16500
|
v = this.compile(schemaKeyRef);
|
|
16497
16501
|
}
|
|
16498
|
-
const
|
|
16502
|
+
const valid15 = v(data);
|
|
16499
16503
|
if (!("$async" in v))
|
|
16500
16504
|
this.errors = v.errors;
|
|
16501
|
-
return
|
|
16505
|
+
return valid15;
|
|
16502
16506
|
}
|
|
16503
16507
|
compile(schema2, _meta) {
|
|
16504
16508
|
const sch = this._addSchema(schema2, _meta);
|
|
@@ -16595,15 +16599,15 @@ var require_core = __commonJS({
|
|
|
16595
16599
|
this.errors = null;
|
|
16596
16600
|
return true;
|
|
16597
16601
|
}
|
|
16598
|
-
const
|
|
16599
|
-
if (!
|
|
16602
|
+
const valid15 = this.validate($schema, schema2);
|
|
16603
|
+
if (!valid15 && throwOrLogError) {
|
|
16600
16604
|
const message = "schema is invalid: " + this.errorsText();
|
|
16601
16605
|
if (this.opts.validateSchema === "log")
|
|
16602
16606
|
this.logger.error(message);
|
|
16603
16607
|
else
|
|
16604
16608
|
throw new Error(message);
|
|
16605
16609
|
}
|
|
16606
|
-
return
|
|
16610
|
+
return valid15;
|
|
16607
16611
|
}
|
|
16608
16612
|
// Get compiled schema by `key` or `ref`.
|
|
16609
16613
|
// (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id)
|
|
@@ -16996,16 +17000,16 @@ var require_ref = __commonJS({
|
|
|
16996
17000
|
}
|
|
16997
17001
|
function inlineRefSchema(sch) {
|
|
16998
17002
|
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch });
|
|
16999
|
-
const
|
|
17003
|
+
const valid15 = gen.name("valid");
|
|
17000
17004
|
const schCxt = cxt.subschema({
|
|
17001
17005
|
schema: sch,
|
|
17002
17006
|
dataTypes: [],
|
|
17003
17007
|
schemaPath: codegen_1.nil,
|
|
17004
17008
|
topSchemaRef: schName,
|
|
17005
17009
|
errSchemaPath: $ref
|
|
17006
|
-
},
|
|
17010
|
+
}, valid15);
|
|
17007
17011
|
cxt.mergeEvaluated(schCxt);
|
|
17008
|
-
cxt.ok(
|
|
17012
|
+
cxt.ok(valid15);
|
|
17009
17013
|
}
|
|
17010
17014
|
}
|
|
17011
17015
|
};
|
|
@@ -17025,19 +17029,19 @@ var require_ref = __commonJS({
|
|
|
17025
17029
|
function callAsyncRef() {
|
|
17026
17030
|
if (!env.$async)
|
|
17027
17031
|
throw new Error("async schema referenced by sync schema");
|
|
17028
|
-
const
|
|
17032
|
+
const valid15 = gen.let("valid");
|
|
17029
17033
|
gen.try(() => {
|
|
17030
17034
|
gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`);
|
|
17031
17035
|
addEvaluatedFrom(v);
|
|
17032
17036
|
if (!allErrors)
|
|
17033
|
-
gen.assign(
|
|
17037
|
+
gen.assign(valid15, true);
|
|
17034
17038
|
}, (e) => {
|
|
17035
17039
|
gen.if((0, codegen_1._)`!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
|
|
17036
17040
|
addErrorsFrom(e);
|
|
17037
17041
|
if (!allErrors)
|
|
17038
|
-
gen.assign(
|
|
17042
|
+
gen.assign(valid15, false);
|
|
17039
17043
|
});
|
|
17040
|
-
cxt.ok(
|
|
17044
|
+
cxt.ok(valid15);
|
|
17041
17045
|
}
|
|
17042
17046
|
function callSyncRef() {
|
|
17043
17047
|
cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
|
|
@@ -17242,9 +17246,9 @@ var require_pattern = __commonJS({
|
|
|
17242
17246
|
if ($data) {
|
|
17243
17247
|
const { regExp } = it.opts.code;
|
|
17244
17248
|
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
17245
|
-
const
|
|
17246
|
-
gen.try(() => gen.assign(
|
|
17247
|
-
cxt.fail$data((0, codegen_1._)`!${
|
|
17249
|
+
const valid15 = gen.let("valid");
|
|
17250
|
+
gen.try(() => gen.assign(valid15, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid15, false));
|
|
17251
|
+
cxt.fail$data((0, codegen_1._)`!${valid15}`);
|
|
17248
17252
|
} else {
|
|
17249
17253
|
const regExp = (0, code_1.usePattern)(cxt, schema2);
|
|
17250
17254
|
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
@@ -17335,9 +17339,9 @@ var require_required = __commonJS({
|
|
|
17335
17339
|
function exitOnErrorMode() {
|
|
17336
17340
|
const missing = gen.let("missing");
|
|
17337
17341
|
if (useLoop || $data) {
|
|
17338
|
-
const
|
|
17339
|
-
cxt.block$data(
|
|
17340
|
-
cxt.ok(
|
|
17342
|
+
const valid15 = gen.let("valid", true);
|
|
17343
|
+
cxt.block$data(valid15, () => loopUntilMissing(missing, valid15));
|
|
17344
|
+
cxt.ok(valid15);
|
|
17341
17345
|
} else {
|
|
17342
17346
|
gen.if((0, code_1.checkMissingProp)(cxt, schema2, missing));
|
|
17343
17347
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
@@ -17350,11 +17354,11 @@ var require_required = __commonJS({
|
|
|
17350
17354
|
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
|
|
17351
17355
|
});
|
|
17352
17356
|
}
|
|
17353
|
-
function loopUntilMissing(missing,
|
|
17357
|
+
function loopUntilMissing(missing, valid15) {
|
|
17354
17358
|
cxt.setParams({ missingProperty: missing });
|
|
17355
17359
|
gen.forOf(missing, schemaCode, () => {
|
|
17356
|
-
gen.assign(
|
|
17357
|
-
gen.if((0, codegen_1.not)(
|
|
17360
|
+
gen.assign(valid15, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
|
|
17361
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
17358
17362
|
cxt.error();
|
|
17359
17363
|
gen.break();
|
|
17360
17364
|
});
|
|
@@ -17429,15 +17433,15 @@ var require_uniqueItems = __commonJS({
|
|
|
17429
17433
|
const { gen, data, $data, schema: schema2, parentSchema, schemaCode, it } = cxt;
|
|
17430
17434
|
if (!$data && !schema2)
|
|
17431
17435
|
return;
|
|
17432
|
-
const
|
|
17436
|
+
const valid15 = gen.let("valid");
|
|
17433
17437
|
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
|
|
17434
|
-
cxt.block$data(
|
|
17435
|
-
cxt.ok(
|
|
17438
|
+
cxt.block$data(valid15, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`);
|
|
17439
|
+
cxt.ok(valid15);
|
|
17436
17440
|
function validateUniqueItems() {
|
|
17437
17441
|
const i = gen.let("i", (0, codegen_1._)`${data}.length`);
|
|
17438
17442
|
const j = gen.let("j");
|
|
17439
17443
|
cxt.setParams({ i, j });
|
|
17440
|
-
gen.assign(
|
|
17444
|
+
gen.assign(valid15, true);
|
|
17441
17445
|
gen.if((0, codegen_1._)`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
|
|
17442
17446
|
}
|
|
17443
17447
|
function canOptimize() {
|
|
@@ -17455,7 +17459,7 @@ var require_uniqueItems = __commonJS({
|
|
|
17455
17459
|
gen.if((0, codegen_1._)`typeof ${indices}[${item}] == "number"`, () => {
|
|
17456
17460
|
gen.assign(j, (0, codegen_1._)`${indices}[${item}]`);
|
|
17457
17461
|
cxt.error();
|
|
17458
|
-
gen.assign(
|
|
17462
|
+
gen.assign(valid15, false).break();
|
|
17459
17463
|
}).code((0, codegen_1._)`${indices}[${item}] = ${i}`);
|
|
17460
17464
|
});
|
|
17461
17465
|
}
|
|
@@ -17464,7 +17468,7 @@ var require_uniqueItems = __commonJS({
|
|
|
17464
17468
|
const outer = gen.name("outer");
|
|
17465
17469
|
gen.label(outer).for((0, codegen_1._)`;${i}--;`, () => gen.for((0, codegen_1._)`${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${data}[${i}], ${data}[${j}])`, () => {
|
|
17466
17470
|
cxt.error();
|
|
17467
|
-
gen.assign(
|
|
17471
|
+
gen.assign(valid15, false).break(outer);
|
|
17468
17472
|
})));
|
|
17469
17473
|
}
|
|
17470
17474
|
}
|
|
@@ -17526,20 +17530,20 @@ var require_enum = __commonJS({
|
|
|
17526
17530
|
const useLoop = schema2.length >= it.opts.loopEnum;
|
|
17527
17531
|
let eql;
|
|
17528
17532
|
const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default);
|
|
17529
|
-
let
|
|
17533
|
+
let valid15;
|
|
17530
17534
|
if (useLoop || $data) {
|
|
17531
|
-
|
|
17532
|
-
cxt.block$data(
|
|
17535
|
+
valid15 = gen.let("valid");
|
|
17536
|
+
cxt.block$data(valid15, loopEnum);
|
|
17533
17537
|
} else {
|
|
17534
17538
|
if (!Array.isArray(schema2))
|
|
17535
17539
|
throw new Error("ajv implementation error");
|
|
17536
17540
|
const vSchema = gen.const("vSchema", schemaCode);
|
|
17537
|
-
|
|
17541
|
+
valid15 = (0, codegen_1.or)(...schema2.map((_x, i) => equalCode(vSchema, i)));
|
|
17538
17542
|
}
|
|
17539
|
-
cxt.pass(
|
|
17543
|
+
cxt.pass(valid15);
|
|
17540
17544
|
function loopEnum() {
|
|
17541
|
-
gen.assign(
|
|
17542
|
-
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(
|
|
17545
|
+
gen.assign(valid15, false);
|
|
17546
|
+
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(valid15, true).break()));
|
|
17543
17547
|
}
|
|
17544
17548
|
function equalCode(vSchema, i) {
|
|
17545
17549
|
const sch = schema2[i];
|
|
@@ -17625,15 +17629,15 @@ var require_additionalItems = __commonJS({
|
|
|
17625
17629
|
cxt.setParams({ len: items.length });
|
|
17626
17630
|
cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
|
|
17627
17631
|
} else if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
|
|
17628
|
-
const
|
|
17629
|
-
gen.if((0, codegen_1.not)(
|
|
17630
|
-
cxt.ok(
|
|
17632
|
+
const valid15 = gen.var("valid", (0, codegen_1._)`${len} <= ${items.length}`);
|
|
17633
|
+
gen.if((0, codegen_1.not)(valid15), () => validateItems(valid15));
|
|
17634
|
+
cxt.ok(valid15);
|
|
17631
17635
|
}
|
|
17632
|
-
function validateItems(
|
|
17636
|
+
function validateItems(valid15) {
|
|
17633
17637
|
gen.forRange("i", items.length, len, (i) => {
|
|
17634
|
-
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num },
|
|
17638
|
+
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid15);
|
|
17635
17639
|
if (!it.allErrors)
|
|
17636
|
-
gen.if((0, codegen_1.not)(
|
|
17640
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
17637
17641
|
});
|
|
17638
17642
|
}
|
|
17639
17643
|
}
|
|
@@ -17672,7 +17676,7 @@ var require_items = __commonJS({
|
|
|
17672
17676
|
if (it.opts.unevaluated && schArr.length && it.items !== true) {
|
|
17673
17677
|
it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
|
|
17674
17678
|
}
|
|
17675
|
-
const
|
|
17679
|
+
const valid15 = gen.name("valid");
|
|
17676
17680
|
const len = gen.const("len", (0, codegen_1._)`${data}.length`);
|
|
17677
17681
|
schArr.forEach((sch, i) => {
|
|
17678
17682
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
@@ -17681,8 +17685,8 @@ var require_items = __commonJS({
|
|
|
17681
17685
|
keyword,
|
|
17682
17686
|
schemaProp: i,
|
|
17683
17687
|
dataProp: i
|
|
17684
|
-
},
|
|
17685
|
-
cxt.ok(
|
|
17688
|
+
}, valid15));
|
|
17689
|
+
cxt.ok(valid15);
|
|
17686
17690
|
});
|
|
17687
17691
|
function checkStrictTuple(sch) {
|
|
17688
17692
|
const { opts, errSchemaPath } = it;
|
|
@@ -17799,18 +17803,18 @@ var require_contains = __commonJS({
|
|
|
17799
17803
|
return;
|
|
17800
17804
|
}
|
|
17801
17805
|
it.items = true;
|
|
17802
|
-
const
|
|
17806
|
+
const valid15 = gen.name("valid");
|
|
17803
17807
|
if (max === void 0 && min === 1) {
|
|
17804
|
-
validateItems(
|
|
17808
|
+
validateItems(valid15, () => gen.if(valid15, () => gen.break()));
|
|
17805
17809
|
} else if (min === 0) {
|
|
17806
|
-
gen.let(
|
|
17810
|
+
gen.let(valid15, true);
|
|
17807
17811
|
if (max !== void 0)
|
|
17808
17812
|
gen.if((0, codegen_1._)`${data}.length > 0`, validateItemsWithCount);
|
|
17809
17813
|
} else {
|
|
17810
|
-
gen.let(
|
|
17814
|
+
gen.let(valid15, false);
|
|
17811
17815
|
validateItemsWithCount();
|
|
17812
17816
|
}
|
|
17813
|
-
cxt.result(
|
|
17817
|
+
cxt.result(valid15, () => cxt.reset());
|
|
17814
17818
|
function validateItemsWithCount() {
|
|
17815
17819
|
const schValid = gen.name("_valid");
|
|
17816
17820
|
const count = gen.let("count", 0);
|
|
@@ -17830,13 +17834,13 @@ var require_contains = __commonJS({
|
|
|
17830
17834
|
function checkLimits(count) {
|
|
17831
17835
|
gen.code((0, codegen_1._)`${count}++`);
|
|
17832
17836
|
if (max === void 0) {
|
|
17833
|
-
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(
|
|
17837
|
+
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid15, true).break());
|
|
17834
17838
|
} else {
|
|
17835
|
-
gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(
|
|
17839
|
+
gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid15, false).break());
|
|
17836
17840
|
if (min === 1)
|
|
17837
|
-
gen.assign(
|
|
17841
|
+
gen.assign(valid15, true);
|
|
17838
17842
|
else
|
|
17839
|
-
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(
|
|
17843
|
+
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid15, true));
|
|
17840
17844
|
}
|
|
17841
17845
|
}
|
|
17842
17846
|
}
|
|
@@ -17918,20 +17922,20 @@ var require_dependencies = __commonJS({
|
|
|
17918
17922
|
exports.validatePropertyDeps = validatePropertyDeps;
|
|
17919
17923
|
function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
|
|
17920
17924
|
const { gen, data, keyword, it } = cxt;
|
|
17921
|
-
const
|
|
17925
|
+
const valid15 = gen.name("valid");
|
|
17922
17926
|
for (const prop in schemaDeps) {
|
|
17923
17927
|
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
|
|
17924
17928
|
continue;
|
|
17925
17929
|
gen.if(
|
|
17926
17930
|
(0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties),
|
|
17927
17931
|
() => {
|
|
17928
|
-
const schCxt = cxt.subschema({ keyword, schemaProp: prop },
|
|
17929
|
-
cxt.mergeValidEvaluated(schCxt,
|
|
17932
|
+
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid15);
|
|
17933
|
+
cxt.mergeValidEvaluated(schCxt, valid15);
|
|
17930
17934
|
},
|
|
17931
|
-
() => gen.var(
|
|
17935
|
+
() => gen.var(valid15, true)
|
|
17932
17936
|
// TODO var
|
|
17933
17937
|
);
|
|
17934
|
-
cxt.ok(
|
|
17938
|
+
cxt.ok(valid15);
|
|
17935
17939
|
}
|
|
17936
17940
|
}
|
|
17937
17941
|
exports.validateSchemaDeps = validateSchemaDeps;
|
|
@@ -17959,7 +17963,7 @@ var require_propertyNames = __commonJS({
|
|
|
17959
17963
|
const { gen, schema: schema2, data, it } = cxt;
|
|
17960
17964
|
if ((0, util_1.alwaysValidSchema)(it, schema2))
|
|
17961
17965
|
return;
|
|
17962
|
-
const
|
|
17966
|
+
const valid15 = gen.name("valid");
|
|
17963
17967
|
gen.forIn("key", data, (key) => {
|
|
17964
17968
|
cxt.setParams({ propertyName: key });
|
|
17965
17969
|
cxt.subschema({
|
|
@@ -17968,14 +17972,14 @@ var require_propertyNames = __commonJS({
|
|
|
17968
17972
|
dataTypes: ["string"],
|
|
17969
17973
|
propertyName: key,
|
|
17970
17974
|
compositeRule: true
|
|
17971
|
-
},
|
|
17972
|
-
gen.if((0, codegen_1.not)(
|
|
17975
|
+
}, valid15);
|
|
17976
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
17973
17977
|
cxt.error(true);
|
|
17974
17978
|
if (!it.allErrors)
|
|
17975
17979
|
gen.break();
|
|
17976
17980
|
});
|
|
17977
17981
|
});
|
|
17978
|
-
cxt.ok(
|
|
17982
|
+
cxt.ok(valid15);
|
|
17979
17983
|
}
|
|
17980
17984
|
};
|
|
17981
17985
|
exports.default = def;
|
|
@@ -18053,21 +18057,21 @@ var require_additionalProperties = __commonJS({
|
|
|
18053
18057
|
return;
|
|
18054
18058
|
}
|
|
18055
18059
|
if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
|
|
18056
|
-
const
|
|
18060
|
+
const valid15 = gen.name("valid");
|
|
18057
18061
|
if (opts.removeAdditional === "failing") {
|
|
18058
|
-
applyAdditionalSchema(key,
|
|
18059
|
-
gen.if((0, codegen_1.not)(
|
|
18062
|
+
applyAdditionalSchema(key, valid15, false);
|
|
18063
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
18060
18064
|
cxt.reset();
|
|
18061
18065
|
deleteAdditional(key);
|
|
18062
18066
|
});
|
|
18063
18067
|
} else {
|
|
18064
|
-
applyAdditionalSchema(key,
|
|
18068
|
+
applyAdditionalSchema(key, valid15);
|
|
18065
18069
|
if (!allErrors)
|
|
18066
|
-
gen.if((0, codegen_1.not)(
|
|
18070
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
18067
18071
|
}
|
|
18068
18072
|
}
|
|
18069
18073
|
}
|
|
18070
|
-
function applyAdditionalSchema(key,
|
|
18074
|
+
function applyAdditionalSchema(key, valid15, errors) {
|
|
18071
18075
|
const subschema = {
|
|
18072
18076
|
keyword: "additionalProperties",
|
|
18073
18077
|
dataProp: key,
|
|
@@ -18080,7 +18084,7 @@ var require_additionalProperties = __commonJS({
|
|
|
18080
18084
|
allErrors: false
|
|
18081
18085
|
});
|
|
18082
18086
|
}
|
|
18083
|
-
cxt.subschema(subschema,
|
|
18087
|
+
cxt.subschema(subschema, valid15);
|
|
18084
18088
|
}
|
|
18085
18089
|
}
|
|
18086
18090
|
};
|
|
@@ -18116,7 +18120,7 @@ var require_properties = __commonJS({
|
|
|
18116
18120
|
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema2[p]));
|
|
18117
18121
|
if (properties.length === 0)
|
|
18118
18122
|
return;
|
|
18119
|
-
const
|
|
18123
|
+
const valid15 = gen.name("valid");
|
|
18120
18124
|
for (const prop of properties) {
|
|
18121
18125
|
if (hasDefault(prop)) {
|
|
18122
18126
|
applyPropertySchema(prop);
|
|
@@ -18124,11 +18128,11 @@ var require_properties = __commonJS({
|
|
|
18124
18128
|
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
|
|
18125
18129
|
applyPropertySchema(prop);
|
|
18126
18130
|
if (!it.allErrors)
|
|
18127
|
-
gen.else().var(
|
|
18131
|
+
gen.else().var(valid15, true);
|
|
18128
18132
|
gen.endIf();
|
|
18129
18133
|
}
|
|
18130
18134
|
cxt.it.definedProperties.add(prop);
|
|
18131
|
-
cxt.ok(
|
|
18135
|
+
cxt.ok(valid15);
|
|
18132
18136
|
}
|
|
18133
18137
|
function hasDefault(prop) {
|
|
18134
18138
|
return it.opts.useDefaults && !it.compositeRule && schema2[prop].default !== void 0;
|
|
@@ -18138,7 +18142,7 @@ var require_properties = __commonJS({
|
|
|
18138
18142
|
keyword: "properties",
|
|
18139
18143
|
schemaProp: prop,
|
|
18140
18144
|
dataProp: prop
|
|
18141
|
-
},
|
|
18145
|
+
}, valid15);
|
|
18142
18146
|
}
|
|
18143
18147
|
}
|
|
18144
18148
|
};
|
|
@@ -18168,7 +18172,7 @@ var require_patternProperties = __commonJS({
|
|
|
18168
18172
|
return;
|
|
18169
18173
|
}
|
|
18170
18174
|
const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
|
|
18171
|
-
const
|
|
18175
|
+
const valid15 = gen.name("valid");
|
|
18172
18176
|
if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
|
|
18173
18177
|
it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
|
|
18174
18178
|
}
|
|
@@ -18181,9 +18185,9 @@ var require_patternProperties = __commonJS({
|
|
|
18181
18185
|
if (it.allErrors) {
|
|
18182
18186
|
validateProperties(pat);
|
|
18183
18187
|
} else {
|
|
18184
|
-
gen.var(
|
|
18188
|
+
gen.var(valid15, true);
|
|
18185
18189
|
validateProperties(pat);
|
|
18186
|
-
gen.if(
|
|
18190
|
+
gen.if(valid15);
|
|
18187
18191
|
}
|
|
18188
18192
|
}
|
|
18189
18193
|
}
|
|
@@ -18204,12 +18208,12 @@ var require_patternProperties = __commonJS({
|
|
|
18204
18208
|
schemaProp: pat,
|
|
18205
18209
|
dataProp: key,
|
|
18206
18210
|
dataPropType: util_2.Type.Str
|
|
18207
|
-
},
|
|
18211
|
+
}, valid15);
|
|
18208
18212
|
}
|
|
18209
18213
|
if (it.opts.unevaluated && props !== true) {
|
|
18210
18214
|
gen.assign((0, codegen_1._)`${props}[${key}]`, true);
|
|
18211
18215
|
} else if (!alwaysValid && !it.allErrors) {
|
|
18212
|
-
gen.if((0, codegen_1.not)(
|
|
18216
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
18213
18217
|
}
|
|
18214
18218
|
});
|
|
18215
18219
|
});
|
|
@@ -18236,14 +18240,14 @@ var require_not = __commonJS({
|
|
|
18236
18240
|
cxt.fail();
|
|
18237
18241
|
return;
|
|
18238
18242
|
}
|
|
18239
|
-
const
|
|
18243
|
+
const valid15 = gen.name("valid");
|
|
18240
18244
|
cxt.subschema({
|
|
18241
18245
|
keyword: "not",
|
|
18242
18246
|
compositeRule: true,
|
|
18243
18247
|
createErrors: false,
|
|
18244
18248
|
allErrors: false
|
|
18245
|
-
},
|
|
18246
|
-
cxt.failResult(
|
|
18249
|
+
}, valid15);
|
|
18250
|
+
cxt.failResult(valid15, () => cxt.reset(), () => cxt.error());
|
|
18247
18251
|
},
|
|
18248
18252
|
error: { message: "must NOT be valid" }
|
|
18249
18253
|
};
|
|
@@ -18291,12 +18295,12 @@ var require_oneOf = __commonJS({
|
|
|
18291
18295
|
if (it.opts.discriminator && parentSchema.discriminator)
|
|
18292
18296
|
return;
|
|
18293
18297
|
const schArr = schema2;
|
|
18294
|
-
const
|
|
18298
|
+
const valid15 = gen.let("valid", false);
|
|
18295
18299
|
const passing = gen.let("passing", null);
|
|
18296
18300
|
const schValid = gen.name("_valid");
|
|
18297
18301
|
cxt.setParams({ passing });
|
|
18298
18302
|
gen.block(validateOneOf);
|
|
18299
|
-
cxt.result(
|
|
18303
|
+
cxt.result(valid15, () => cxt.reset(), () => cxt.error(true));
|
|
18300
18304
|
function validateOneOf() {
|
|
18301
18305
|
schArr.forEach((sch, i) => {
|
|
18302
18306
|
let schCxt;
|
|
@@ -18310,10 +18314,10 @@ var require_oneOf = __commonJS({
|
|
|
18310
18314
|
}, schValid);
|
|
18311
18315
|
}
|
|
18312
18316
|
if (i > 0) {
|
|
18313
|
-
gen.if((0, codegen_1._)`${schValid} && ${
|
|
18317
|
+
gen.if((0, codegen_1._)`${schValid} && ${valid15}`).assign(valid15, false).assign(passing, (0, codegen_1._)`[${passing}, ${i}]`).else();
|
|
18314
18318
|
}
|
|
18315
18319
|
gen.if(schValid, () => {
|
|
18316
|
-
gen.assign(
|
|
18320
|
+
gen.assign(valid15, true);
|
|
18317
18321
|
gen.assign(passing, i);
|
|
18318
18322
|
if (schCxt)
|
|
18319
18323
|
cxt.mergeEvaluated(schCxt, codegen_1.Name);
|
|
@@ -18339,12 +18343,12 @@ var require_allOf = __commonJS({
|
|
|
18339
18343
|
const { gen, schema: schema2, it } = cxt;
|
|
18340
18344
|
if (!Array.isArray(schema2))
|
|
18341
18345
|
throw new Error("ajv implementation error");
|
|
18342
|
-
const
|
|
18346
|
+
const valid15 = gen.name("valid");
|
|
18343
18347
|
schema2.forEach((sch, i) => {
|
|
18344
18348
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
18345
18349
|
return;
|
|
18346
|
-
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i },
|
|
18347
|
-
cxt.ok(
|
|
18350
|
+
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid15);
|
|
18351
|
+
cxt.ok(valid15);
|
|
18348
18352
|
cxt.mergeEvaluated(schCxt);
|
|
18349
18353
|
});
|
|
18350
18354
|
}
|
|
@@ -18378,7 +18382,7 @@ var require_if = __commonJS({
|
|
|
18378
18382
|
const hasElse = hasSchema(it, "else");
|
|
18379
18383
|
if (!hasThen && !hasElse)
|
|
18380
18384
|
return;
|
|
18381
|
-
const
|
|
18385
|
+
const valid15 = gen.let("valid", true);
|
|
18382
18386
|
const schValid = gen.name("_valid");
|
|
18383
18387
|
validateIf();
|
|
18384
18388
|
cxt.reset();
|
|
@@ -18391,7 +18395,7 @@ var require_if = __commonJS({
|
|
|
18391
18395
|
} else {
|
|
18392
18396
|
gen.if((0, codegen_1.not)(schValid), validateClause("else"));
|
|
18393
18397
|
}
|
|
18394
|
-
cxt.pass(
|
|
18398
|
+
cxt.pass(valid15, () => cxt.error(true));
|
|
18395
18399
|
function validateIf() {
|
|
18396
18400
|
const schCxt = cxt.subschema({
|
|
18397
18401
|
keyword: "if",
|
|
@@ -18404,8 +18408,8 @@ var require_if = __commonJS({
|
|
|
18404
18408
|
function validateClause(keyword, ifClause) {
|
|
18405
18409
|
return () => {
|
|
18406
18410
|
const schCxt = cxt.subschema({ keyword }, schValid);
|
|
18407
|
-
gen.assign(
|
|
18408
|
-
cxt.mergeValidEvaluated(schCxt,
|
|
18411
|
+
gen.assign(valid15, schValid);
|
|
18412
|
+
cxt.mergeValidEvaluated(schCxt, valid15);
|
|
18409
18413
|
if (ifClause)
|
|
18410
18414
|
gen.assign(ifClause, (0, codegen_1._)`${keyword}`);
|
|
18411
18415
|
else
|
|
@@ -18680,16 +18684,16 @@ var require_discriminator = __commonJS({
|
|
|
18680
18684
|
throw new Error("discriminator: mapping is not supported");
|
|
18681
18685
|
if (!oneOf)
|
|
18682
18686
|
throw new Error("discriminator: requires oneOf keyword");
|
|
18683
|
-
const
|
|
18687
|
+
const valid15 = gen.let("valid", false);
|
|
18684
18688
|
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`);
|
|
18685
18689
|
gen.if((0, codegen_1._)`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
|
|
18686
|
-
cxt.ok(
|
|
18690
|
+
cxt.ok(valid15);
|
|
18687
18691
|
function validateMapping() {
|
|
18688
18692
|
const mapping = getMapping();
|
|
18689
18693
|
gen.if(false);
|
|
18690
18694
|
for (const tagValue in mapping) {
|
|
18691
18695
|
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
|
|
18692
|
-
gen.assign(
|
|
18696
|
+
gen.assign(valid15, applyTagSchema(mapping[tagValue]));
|
|
18693
18697
|
}
|
|
18694
18698
|
gen.else();
|
|
18695
18699
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
|
|
@@ -19382,7 +19386,7 @@ var init_contract = __esm({
|
|
|
19382
19386
|
host: identifier,
|
|
19383
19387
|
id: typebox_exports.String(),
|
|
19384
19388
|
kind: typebox_exports.Union([typebox_exports.Literal("session"), typebox_exports.Literal("exchange"), typebox_exports.Literal("summary")], {
|
|
19385
|
-
description: "session
|
|
19389
|
+
description: "session \u4E3A\u4F1A\u8BDD\uFF0Csummary \u4E3A\u6458\u8981\uFF0Cexchange \u4E3A\u5355\u8F6E\u95EE\u7B54\u539F\u6587\u3002"
|
|
19386
19390
|
}),
|
|
19387
19391
|
dimension: typebox_exports.Optional(identifier),
|
|
19388
19392
|
sessionId: typebox_exports.String(),
|
|
@@ -19391,7 +19395,7 @@ var init_contract = __esm({
|
|
|
19391
19395
|
from: typebox_exports.String(),
|
|
19392
19396
|
to: typebox_exports.String(),
|
|
19393
19397
|
ready: typebox_exports.Boolean({ description: "\u6B63\u6587\u6216\u6458\u8981\u662F\u5426\u5DF2\u751F\u6210\u3002" }),
|
|
19394
|
-
completed: typebox_exports.Boolean({ description: "\
|
|
19398
|
+
completed: typebox_exports.Boolean({ description: "false \u8868\u793A\u4F1A\u8BDD\u6216\u95EE\u7B54\u4E2D\u65AD\u6216\u672A\u5B8C\u6210\u3002" })
|
|
19395
19399
|
});
|
|
19396
19400
|
historyResultSchema = typebox_exports.Object({
|
|
19397
19401
|
matches: typebox_exports.Optional(typebox_exports.Array(typebox_exports.Object({
|
|
@@ -19421,18 +19425,18 @@ var init_contract = __esm({
|
|
|
19421
19425
|
});
|
|
19422
19426
|
historyParameters = typebox_exports.Object({
|
|
19423
19427
|
action: typebox_exports.Union([typebox_exports.Literal("search"), typebox_exports.Literal("read")], {
|
|
19424
|
-
description: "search \u641C\u7D22\u6216\u5217\
|
|
19428
|
+
description: "search \u641C\u7D22\u6216\u5217\u51FA\u8BB0\u5F55\uFF0Cread \u6309 id \u8BFB\u53D6\u6B63\u6587\u548C\u4E0A\u4E0B\u7EA7\u3002"
|
|
19425
19429
|
}),
|
|
19426
|
-
host: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\u6765\u6E90\u5BBF\u4E3B\
|
|
19427
|
-
dimension: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "
|
|
19428
|
-
query: nullable(typebox_exports.String({ description: "
|
|
19429
|
-
sessionId: nullable(typebox_exports.String({ description: "
|
|
19430
|
-
from: nullable(typebox_exports.String({ description: "
|
|
19431
|
-
to: nullable(typebox_exports.String({ description: "\u4EC5
|
|
19432
|
-
id: nullable(typebox_exports.String({ description: "
|
|
19433
|
-
offset: nullable(typebox_exports.Integer({ minimum: 0, description: "
|
|
19434
|
-
limit: nullable(typebox_exports.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search\
|
|
19435
|
-
childrenOffset: nullable(typebox_exports.Integer({ minimum: 0, description: "
|
|
19430
|
+
host: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\u6765\u6E90\u5BBF\u4E3B\uFF0C\u5982 pi \u6216 claude\u3002\u53EF\u7B5B\u9009\u641C\u7D22\u7ED3\u679C\u6216\u533A\u5206\u91CD\u540D\u8282\u70B9\u3002" })),
|
|
19431
|
+
dimension: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "search \u7684\u8303\u56F4\u3002raw \u4E3A\u539F\u59CB\u95EE\u7B54\uFF0Csession\u3001monthly \u7B49\u4E3A\u6458\u8981\u7EF4\u5EA6\u3002\u5173\u952E\u8BCD\u641C\u7D22\u9ED8\u8BA4\u67E5\u5168\u90E8\u3002" })),
|
|
19432
|
+
query: nullable(typebox_exports.String({ description: "search \u5339\u914D\u8FDE\u7EED\u6587\u672C\uFF0C\u5FFD\u7565\u5927\u5C0F\u5199\u3002\u7701\u7565\u65F6\u5217\u4F1A\u8BDD\uFF0C\u6307\u5B9A\u6458\u8981\u7EF4\u5EA6\u5219\u5217\u8BE5\u7EF4\u5EA6\u7684\u6458\u8981\u3002" })),
|
|
19433
|
+
sessionId: nullable(typebox_exports.String({ description: "search \u6309\u539F\u59CB\u4F1A\u8BDD ID \u7B5B\u9009\u3002" })),
|
|
19434
|
+
from: nullable(typebox_exports.String({ description: "search \u65F6\u95F4\u533A\u95F4\u8D77\u70B9\uFF08\u542B\uFF09\uFF0C\u7528 ISO \u65E5\u671F\u6216\u65F6\u95F4\u3002" })),
|
|
19435
|
+
to: nullable(typebox_exports.String({ description: "search \u65F6\u95F4\u533A\u95F4\u7EC8\u70B9\uFF08\u542B\uFF09\uFF0C\u4EC5\u586B\u65E5\u671F\u8868\u793A\u8BE5\u65E5 UTC \u96F6\u70B9\u3002" })),
|
|
19436
|
+
id: nullable(typebox_exports.String({ description: "read \u5FC5\u586B\u3002\u4F7F\u7528\u641C\u7D22\u7ED3\u679C\u3001\u7236\u8282\u70B9\u6216\u5B50\u8282\u70B9\u7684 id\u3002" })),
|
|
19437
|
+
offset: nullable(typebox_exports.Integer({ minimum: 0, description: "\u7FFB\u9875\u4F20\u4E0A\u9875\u7684 nextOffset\u3002search \u6309\u6761\u76EE\uFF0Cread \u6309\u6B63\u6587\u5B57\u7B26\uFF0C\u9ED8\u8BA4\u4ECE 0 \u5F00\u59CB\u3002" })),
|
|
19438
|
+
limit: nullable(typebox_exports.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search \u6BCF\u9875\u9ED8\u8BA4 ${historyPageLimits.search.default} \u6761\uFF0C\u6700\u591A ${historyPageLimits.search.max} \u6761\u3002read \u6BCF\u9875\u9ED8\u8BA4 ${historyPageLimits.read.default} \u4E2A\u5B57\u7B26\u3002` })),
|
|
19439
|
+
childrenOffset: nullable(typebox_exports.Integer({ minimum: 0, description: "read \u7684\u5B50\u8282\u70B9\u8D77\u70B9\uFF0C\u9ED8\u8BA4 0\u3002\u7FFB\u9875\u4F20\u4E0A\u9875\u7684 nextChildrenOffset\u3002" }))
|
|
19436
19440
|
}, { additionalProperties: false });
|
|
19437
19441
|
valid2 = schema(historyParameters);
|
|
19438
19442
|
}
|
|
@@ -19509,7 +19513,7 @@ var init_command = __esm({
|
|
|
19509
19513
|
});
|
|
19510
19514
|
|
|
19511
19515
|
// src/extension/cli/index.ts
|
|
19512
|
-
var
|
|
19516
|
+
var import_semver13 = __toESM(require_semver2(), 1);
|
|
19513
19517
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
19514
19518
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
19515
19519
|
|
|
@@ -19537,8 +19541,8 @@ import { lstat, mkdir, readFile, realpath, rmdir } from "node:fs/promises";
|
|
|
19537
19541
|
import { homedir } from "node:os";
|
|
19538
19542
|
import { dirname, join } from "node:path";
|
|
19539
19543
|
import { promisify } from "node:util";
|
|
19540
|
-
async function minimumCliRelease(root
|
|
19541
|
-
const versions =
|
|
19544
|
+
async function minimumCliRelease(root) {
|
|
19545
|
+
const versions = [];
|
|
19542
19546
|
if (process.env.PBOT_PLUGIN_VERSION) versions.push(process.env.PBOT_PLUGIN_VERSION);
|
|
19543
19547
|
for (const prefix of ["", ".pi/npm"]) {
|
|
19544
19548
|
const path = join(root, prefix, "node_modules/personal-bot/package.json");
|
|
@@ -19672,125 +19676,23 @@ async function runUpdatedCli(required, args, input) {
|
|
|
19672
19676
|
return runProgram("npx", ["--yes", "--ignore-scripts", "--prefer-offline", "personal-bot@" + required, ...args], env, false, input);
|
|
19673
19677
|
}
|
|
19674
19678
|
|
|
19675
|
-
// src/services/workspace/plugin-releases.ts
|
|
19676
|
-
init_json();
|
|
19677
|
-
init_paths();
|
|
19678
|
-
init_validation();
|
|
19679
|
-
import { createHash } from "node:crypto";
|
|
19680
|
-
import { mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
19681
|
-
import { homedir as homedir2 } from "node:os";
|
|
19682
|
-
import { isAbsolute, join as join3, resolve as resolve2 } from "node:path";
|
|
19683
|
-
init_atomic_json();
|
|
19684
|
-
function compareSemver(a, b) {
|
|
19685
|
-
const parse = (value) => {
|
|
19686
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
|
|
19687
|
-
return match ? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" } : void 0;
|
|
19688
|
-
};
|
|
19689
|
-
const left = parse(a);
|
|
19690
|
-
const right = parse(b);
|
|
19691
|
-
if (!left || !right) return a.localeCompare(b);
|
|
19692
|
-
if (left.major !== right.major) return left.major - right.major;
|
|
19693
|
-
if (left.minor !== right.minor) return left.minor - right.minor;
|
|
19694
|
-
if (left.patch !== right.patch) return left.patch - right.patch;
|
|
19695
|
-
if (left.pre === right.pre) return 0;
|
|
19696
|
-
if (!left.pre) return 1;
|
|
19697
|
-
if (!right.pre) return -1;
|
|
19698
|
-
return left.pre.localeCompare(right.pre);
|
|
19699
|
-
}
|
|
19700
|
-
function bindingDirectory(root) {
|
|
19701
|
-
const key = createHash("sha256").update(root).digest("hex");
|
|
19702
|
-
return join3(homedir2(), ".pbot", "workspaces", key);
|
|
19703
|
-
}
|
|
19704
|
-
function pluginBinding(value) {
|
|
19705
|
-
requireThat(typeof value === "string", "\u65E0\u6548\u7684\u63D2\u4EF6\u5B89\u88C5\u8BB0\u5F55\u3002");
|
|
19706
|
-
if (!isAbsolute(value)) releaseLine(value);
|
|
19707
|
-
return value;
|
|
19708
|
-
}
|
|
19709
|
-
function permissionDenied(error) {
|
|
19710
|
-
return ["EACCES", "EPERM", "EROFS"].includes(error.code ?? "");
|
|
19711
|
-
}
|
|
19712
|
-
function bindWorkspacePlugin(root, host, binding = resolve2(resourceRoot, "../package.json")) {
|
|
19713
|
-
const directory = bindingDirectory(root);
|
|
19714
|
-
const file = encodeURIComponent(host) + ".json";
|
|
19715
|
-
try {
|
|
19716
|
-
if (readJsonFile(directory, file, pluginBinding) === binding) return;
|
|
19717
|
-
} catch (error) {
|
|
19718
|
-
if (permissionDenied(error)) return;
|
|
19719
|
-
if (error.code !== "ENOENT") throw error;
|
|
19720
|
-
}
|
|
19721
|
-
try {
|
|
19722
|
-
mkdirSync2(directory, { recursive: true, mode: 448 });
|
|
19723
|
-
writeJsonFile(directory, file, binding, pluginBinding);
|
|
19724
|
-
} catch (error) {
|
|
19725
|
-
if (!permissionDenied(error)) throw error;
|
|
19726
|
-
}
|
|
19727
|
-
}
|
|
19728
|
-
function workspacePluginBindings(root) {
|
|
19729
|
-
const directory = bindingDirectory(root);
|
|
19730
|
-
let files;
|
|
19731
|
-
try {
|
|
19732
|
-
files = readdirSync(directory);
|
|
19733
|
-
} catch (error) {
|
|
19734
|
-
if (error.code === "ENOENT" || permissionDenied(error)) return {};
|
|
19735
|
-
throw error;
|
|
19736
|
-
}
|
|
19737
|
-
const bindings = /* @__PURE__ */ Object.create(null);
|
|
19738
|
-
for (const file of files.filter((name) => name.endsWith(".json"))) {
|
|
19739
|
-
const host = decodeURIComponent(file.slice(0, -5));
|
|
19740
|
-
try {
|
|
19741
|
-
const binding = readJsonFile(directory, file, pluginBinding);
|
|
19742
|
-
if (!isAbsolute(binding)) {
|
|
19743
|
-
bindings[host] = { version: binding };
|
|
19744
|
-
continue;
|
|
19745
|
-
}
|
|
19746
|
-
const manifest2 = JSON.parse(readFileSync3(binding, "utf8"));
|
|
19747
|
-
requireThat(object(manifest2) && typeof manifest2.version === "string", "\u65E0\u6548\u7684\u63D2\u4EF6\u5B89\u88C5\u6E05\u5355\uFF1A" + binding);
|
|
19748
|
-
releaseLine(manifest2.version);
|
|
19749
|
-
bindings[host] = { version: manifest2.version, bindingPath: binding };
|
|
19750
|
-
} catch (error) {
|
|
19751
|
-
if (error.code !== "ENOENT" && !permissionDenied(error)) throw error;
|
|
19752
|
-
}
|
|
19753
|
-
}
|
|
19754
|
-
return bindings;
|
|
19755
|
-
}
|
|
19756
|
-
function workspacePluginReleases(root) {
|
|
19757
|
-
const bindings = workspacePluginBindings(root);
|
|
19758
|
-
const releases = /* @__PURE__ */ Object.create(null);
|
|
19759
|
-
for (const [host, entry] of Object.entries(bindings)) releases[host] = entry.version;
|
|
19760
|
-
return releases;
|
|
19761
|
-
}
|
|
19762
|
-
function workspacePluginDrift(releases) {
|
|
19763
|
-
let highest;
|
|
19764
|
-
let lowest;
|
|
19765
|
-
for (const version of Object.values(releases)) {
|
|
19766
|
-
if (!highest || compareSemver(version, highest) > 0) highest = version;
|
|
19767
|
-
if (!lowest || compareSemver(version, lowest) < 0) lowest = version;
|
|
19768
|
-
}
|
|
19769
|
-
return {
|
|
19770
|
-
outOfSync: Boolean(highest && lowest && highest !== lowest),
|
|
19771
|
-
...highest ? { highest } : {},
|
|
19772
|
-
...lowest ? { lowest } : {},
|
|
19773
|
-
versions: releases
|
|
19774
|
-
};
|
|
19775
|
-
}
|
|
19776
|
-
|
|
19777
19679
|
// src/extension/cli/index.ts
|
|
19778
19680
|
init_workspace_config2();
|
|
19779
19681
|
|
|
19780
19682
|
// src/extension/cli/args.ts
|
|
19781
19683
|
init_validation();
|
|
19782
|
-
import { homedir as
|
|
19684
|
+
import { homedir as homedir2 } from "node:os";
|
|
19783
19685
|
|
|
19784
19686
|
// src/integrations/installation/workspace.ts
|
|
19785
19687
|
import { stat, realpath as realpath2 } from "node:fs/promises";
|
|
19786
|
-
import { dirname as dirname4, join as
|
|
19688
|
+
import { dirname as dirname4, join as join4, relative, resolve as resolve2 } from "node:path";
|
|
19787
19689
|
async function resolveWorkspace(value, cwd, home) {
|
|
19788
|
-
const path =
|
|
19690
|
+
const path = resolve2(cwd, value === "~" ? home : value.startsWith("~/") ? join4(home, value.slice(2)) : value);
|
|
19789
19691
|
let existing = path;
|
|
19790
19692
|
while (true) {
|
|
19791
19693
|
try {
|
|
19792
19694
|
if (!(await stat(existing)).isDirectory()) throw new Error("\u5DE5\u4F5C\u533A\u6216\u5176\u7236\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A" + existing);
|
|
19793
|
-
return
|
|
19695
|
+
return resolve2(await realpath2(existing), relative(existing, path));
|
|
19794
19696
|
} catch (error) {
|
|
19795
19697
|
if (error.code !== "ENOENT") throw error;
|
|
19796
19698
|
const parent = dirname4(existing);
|
|
@@ -19854,7 +19756,7 @@ function printJson(value, compact) {
|
|
|
19854
19756
|
console.log(JSON.stringify(value, null, compact ? void 0 : 2));
|
|
19855
19757
|
}
|
|
19856
19758
|
function resolveCliWorkspace(workspace, cwd) {
|
|
19857
|
-
return resolveWorkspace(workspace ?? cwd, cwd,
|
|
19759
|
+
return resolveWorkspace(workspace ?? cwd, cwd, homedir2());
|
|
19858
19760
|
}
|
|
19859
19761
|
function requireNoExtraArgs(args, usage) {
|
|
19860
19762
|
if (args.length > 0) throw new CliError(`\u4E0D\u652F\u6301\u7684\u53C2\u6570\uFF1A${args[0]}
|
|
@@ -19978,7 +19880,7 @@ init_validation();
|
|
|
19978
19880
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
19979
19881
|
init_json();
|
|
19980
19882
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
19981
|
-
import { join as
|
|
19883
|
+
import { join as join14 } from "node:path";
|
|
19982
19884
|
async function readManifestVersion(path) {
|
|
19983
19885
|
try {
|
|
19984
19886
|
const data = JSON.parse(await readFile3(path, "utf8"));
|
|
@@ -20000,8 +19902,8 @@ var antigravityInstaller = {
|
|
|
20000
19902
|
detail: "\u672A\u627E\u5230 Antigravity CLI\uFF08agy\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 agy \u540E\u91CD\u8BD5\u3002"
|
|
20001
19903
|
};
|
|
20002
19904
|
}
|
|
20003
|
-
const pluginDir =
|
|
20004
|
-
const bundledVersion = await readManifestVersion(
|
|
19905
|
+
const pluginDir = join14(context.packageRoot, "lib", "antigravity-plugin");
|
|
19906
|
+
const bundledVersion = await readManifestVersion(join14(pluginDir, "plugin.json"));
|
|
20005
19907
|
if (!bundledVersion) {
|
|
20006
19908
|
return {
|
|
20007
19909
|
host: this.host,
|
|
@@ -20032,20 +19934,20 @@ var claudeInstaller = {
|
|
|
20032
19934
|
return {
|
|
20033
19935
|
host: this.host,
|
|
20034
19936
|
state: context.explicit ? "failed" : "skipped",
|
|
20035
|
-
scope: "
|
|
19937
|
+
scope: "project",
|
|
20036
19938
|
detail: "\u672A\u627E\u5230 Claude Code CLI\uFF08claude\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Claude Code \u540E\u91CD\u8BD5\u3002"
|
|
20037
19939
|
};
|
|
20038
19940
|
}
|
|
20039
19941
|
await context.run(
|
|
20040
19942
|
claude,
|
|
20041
|
-
["plugin", "install", "personal-bot", "--marketplace", claudeMarketplace, "--yes"],
|
|
19943
|
+
["plugin", "install", "personal-bot", "--marketplace", claudeMarketplace, "--scope", "project", "--yes"],
|
|
20042
19944
|
context.workspace
|
|
20043
19945
|
);
|
|
20044
19946
|
return {
|
|
20045
19947
|
host: this.host,
|
|
20046
19948
|
state: "installed",
|
|
20047
|
-
scope: "
|
|
20048
|
-
detail: `\u5DF2\u901A\u8FC7 claude plugin install \u4ECE ${claudeMarketplace} \u5B89\u88C5 personal-bot\u3002`,
|
|
19949
|
+
scope: "project",
|
|
19950
|
+
detail: `\u5DF2\u901A\u8FC7 claude plugin install\uFF08project \u4F5C\u7528\u57DF\uFF09\u4ECE ${claudeMarketplace} \u5B89\u88C5 personal-bot\u3002`,
|
|
20049
19951
|
nextStep: "\u5728 Claude Code \u76EE\u6807\u5DE5\u4F5C\u533A\u6267\u884C /personal-bot:pbot init \u542F\u7528 Personal Bot\u3002"
|
|
20050
19952
|
};
|
|
20051
19953
|
}
|
|
@@ -20055,7 +19957,7 @@ var claudeInstaller = {
|
|
|
20055
19957
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
20056
19958
|
init_json();
|
|
20057
19959
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
20058
|
-
import { join as
|
|
19960
|
+
import { join as join15 } from "node:path";
|
|
20059
19961
|
async function readManifestVersion2(path) {
|
|
20060
19962
|
try {
|
|
20061
19963
|
const data = JSON.parse(await readFile4(path, "utf8"));
|
|
@@ -20077,9 +19979,9 @@ var codexInstaller = {
|
|
|
20077
19979
|
detail: "\u672A\u627E\u5230 Codex CLI\uFF08codex\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Codex CLI \u540E\u91CD\u8BD5\u3002"
|
|
20078
19980
|
};
|
|
20079
19981
|
}
|
|
20080
|
-
const marketplaceDir =
|
|
19982
|
+
const marketplaceDir = join15(context.packageRoot, "lib", "codex-marketplace");
|
|
20081
19983
|
const bundledVersion = await readManifestVersion2(
|
|
20082
|
-
|
|
19984
|
+
join15(marketplaceDir, "plugins", "personal-bot", ".codex-plugin", "plugin.json")
|
|
20083
19985
|
);
|
|
20084
19986
|
if (!bundledVersion) {
|
|
20085
19987
|
return {
|
|
@@ -20159,7 +20061,7 @@ var piInstaller = {
|
|
|
20159
20061
|
var import_semver4 = __toESM(require_semver2(), 1);
|
|
20160
20062
|
init_json();
|
|
20161
20063
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
20162
|
-
import { join as
|
|
20064
|
+
import { join as join16 } from "node:path";
|
|
20163
20065
|
async function readManifestVersion3(path) {
|
|
20164
20066
|
try {
|
|
20165
20067
|
const data = JSON.parse(await readFile5(path, "utf8"));
|
|
@@ -20177,27 +20079,27 @@ var qoderInstaller = {
|
|
|
20177
20079
|
return {
|
|
20178
20080
|
host: this.host,
|
|
20179
20081
|
state: context.explicit ? "failed" : "skipped",
|
|
20180
|
-
scope: "
|
|
20082
|
+
scope: "project",
|
|
20181
20083
|
detail: "\u672A\u627E\u5230 Qoder CLI\uFF08qodercli\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Qoder CLI \u540E\u91CD\u8BD5\u3002"
|
|
20182
20084
|
};
|
|
20183
20085
|
}
|
|
20184
|
-
const pluginDir =
|
|
20185
|
-
const bundledVersion = await readManifestVersion3(
|
|
20086
|
+
const pluginDir = join16(context.packageRoot, "lib", "qoder-plugin");
|
|
20087
|
+
const bundledVersion = await readManifestVersion3(join16(pluginDir, ".qoder-plugin", "plugin.json"));
|
|
20186
20088
|
if (!bundledVersion) {
|
|
20187
20089
|
return {
|
|
20188
20090
|
host: this.host,
|
|
20189
20091
|
state: "failed",
|
|
20190
|
-
scope: "
|
|
20092
|
+
scope: "project",
|
|
20191
20093
|
detail: `\u7F3A\u5C11 Qoder CLI \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}\u3002\u8BF7\u5148\u8FD0\u884C npm run build\u3002`
|
|
20192
20094
|
};
|
|
20193
20095
|
}
|
|
20194
|
-
await context.run(qodercli, ["plugin", "install", pluginDir], context.workspace);
|
|
20096
|
+
await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", "project"], context.workspace);
|
|
20195
20097
|
return {
|
|
20196
20098
|
host: this.host,
|
|
20197
20099
|
state: "installed",
|
|
20198
20100
|
version: bundledVersion,
|
|
20199
|
-
scope: "
|
|
20200
|
-
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install \u5B89\u88C5 Qoder CLI \u63D2\u4EF6\uFF08${bundledVersion}\uFF09\u3002`,
|
|
20101
|
+
scope: "project",
|
|
20102
|
+
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install\uFF08project \u4F5C\u7528\u57DF\uFF09\u5B89\u88C5 Qoder CLI \u63D2\u4EF6\uFF08${bundledVersion}\uFF09\u3002`,
|
|
20201
20103
|
nextStep: "\u5728\u76EE\u6807\u5DE5\u4F5C\u533A\u6267\u884C pbot plugin qoder init \u542F\u7528 Personal Bot\u3002"
|
|
20202
20104
|
};
|
|
20203
20105
|
}
|
|
@@ -20239,11 +20141,11 @@ var listHostInstallers = () => hostInstallers.list();
|
|
|
20239
20141
|
import { spawn as spawn2 } from "node:child_process";
|
|
20240
20142
|
import { access, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
20241
20143
|
import { constants as constants3 } from "node:fs";
|
|
20242
|
-
import { delimiter as delimiter2, isAbsolute as
|
|
20144
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute2, resolve as resolve7 } from "node:path";
|
|
20243
20145
|
async function findExecutable(name, env = process.env) {
|
|
20244
20146
|
const directories2 = (env.PATH ?? "").split(delimiter2).filter(Boolean);
|
|
20245
20147
|
for (const directory of directories2) {
|
|
20246
|
-
const path =
|
|
20148
|
+
const path = resolve7(directory, name);
|
|
20247
20149
|
if (name === "pi" && path.split(/[\\/]/).includes("_npx")) continue;
|
|
20248
20150
|
try {
|
|
20249
20151
|
await access(path, constants3.X_OK);
|
|
@@ -20264,7 +20166,7 @@ var SetupProcesses = class {
|
|
|
20264
20166
|
}
|
|
20265
20167
|
async run(command, args, cwd, options = {}) {
|
|
20266
20168
|
this.signal.throwIfAborted();
|
|
20267
|
-
if (!
|
|
20169
|
+
if (!isAbsolute2(cwd)) throw new Error("\u8FDB\u7A0B\u5DE5\u4F5C\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20268
20170
|
const interactive = options.interactive ?? false;
|
|
20269
20171
|
const timeoutMs = options.timeoutMs ?? (interactive ? 15 * 6e4 : 6e4);
|
|
20270
20172
|
return new Promise((resolveResult, reject) => {
|
|
@@ -20481,7 +20383,7 @@ var installCommand = {
|
|
|
20481
20383
|
init_paths();
|
|
20482
20384
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
20483
20385
|
import { existsSync as existsSync2 } from "node:fs";
|
|
20484
|
-
import { join as
|
|
20386
|
+
import { join as join19 } from "node:path";
|
|
20485
20387
|
|
|
20486
20388
|
// src/integrations/hosts/plugin-registry.ts
|
|
20487
20389
|
init_validation();
|
|
@@ -20491,7 +20393,7 @@ init_json();
|
|
|
20491
20393
|
init_paths();
|
|
20492
20394
|
init_validation();
|
|
20493
20395
|
import { readFile as readFile6, realpath as realpath4, stat as stat4 } from "node:fs/promises";
|
|
20494
|
-
import { dirname as dirname6, isAbsolute as
|
|
20396
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, relative as relative3, resolve as resolve8, sep } from "node:path";
|
|
20495
20397
|
var supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
|
|
20496
20398
|
function cleanUserRequest(content) {
|
|
20497
20399
|
const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
@@ -20541,7 +20443,7 @@ function projectAntigravityTranscript(sessionId, content, terminationReason) {
|
|
|
20541
20443
|
return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
|
|
20542
20444
|
}
|
|
20543
20445
|
async function readAntigravityTranscript(transcriptPath) {
|
|
20544
|
-
const fullPath =
|
|
20446
|
+
const fullPath = join17(dirname6(transcriptPath), "transcript_full.jsonl");
|
|
20545
20447
|
for (const path of [fullPath, transcriptPath]) {
|
|
20546
20448
|
try {
|
|
20547
20449
|
return await readFile6(path, "utf8");
|
|
@@ -20558,10 +20460,10 @@ function workspaceFromPayload(cwd, payload) {
|
|
|
20558
20460
|
}
|
|
20559
20461
|
return cwd;
|
|
20560
20462
|
}
|
|
20561
|
-
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT ||
|
|
20562
|
-
const skillsRoot =
|
|
20563
|
-
const rel = relative3(skillsRoot,
|
|
20564
|
-
if (!rel || rel.startsWith("..") ||
|
|
20463
|
+
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve8(resourceRoot, "..")) {
|
|
20464
|
+
const skillsRoot = resolve8(pluginRoot, "skills");
|
|
20465
|
+
const rel = relative3(skillsRoot, resolve8(targetPath));
|
|
20466
|
+
if (!rel || rel.startsWith("..") || isAbsolute3(rel)) return void 0;
|
|
20565
20467
|
const skill = rel.split(sep)[0];
|
|
20566
20468
|
if (!skill || skill === "pbot") return void 0;
|
|
20567
20469
|
return skill;
|
|
@@ -20571,7 +20473,7 @@ function isPreToolUse(payload) {
|
|
|
20571
20473
|
}
|
|
20572
20474
|
async function antigravityWorkspaceRoot(cwd, payload) {
|
|
20573
20475
|
const directory = workspaceFromPayload(cwd, payload);
|
|
20574
|
-
requireThat(
|
|
20476
|
+
requireThat(isAbsolute3(directory), "Antigravity \u5DE5\u4F5C\u533A\u9700\u8981\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20575
20477
|
const root = await realpath4(directory);
|
|
20576
20478
|
requireThat((await stat4(root)).isDirectory(), "Antigravity \u5DE5\u4F5C\u533A\u9700\u8981\u76EE\u5F55\u3002");
|
|
20577
20479
|
return root;
|
|
@@ -20580,7 +20482,6 @@ var antigravityAdapter = {
|
|
|
20580
20482
|
host: "antigravity",
|
|
20581
20483
|
nativeRootAgents: true,
|
|
20582
20484
|
nativeWorkspaceSkills: true,
|
|
20583
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
20584
20485
|
initCommandHint: "/pbot init",
|
|
20585
20486
|
usage: "\u7528\u6CD5\uFF1Anode <\u63D2\u4EF6\u76EE\u5F55>/lib/plugin.js antigravity init|status",
|
|
20586
20487
|
resolveRoot(cwd, rawPayload) {
|
|
@@ -20648,9 +20549,9 @@ init_validation();
|
|
|
20648
20549
|
init_json();
|
|
20649
20550
|
init_validation();
|
|
20650
20551
|
import { realpath as realpath5, stat as stat5 } from "node:fs/promises";
|
|
20651
|
-
import { isAbsolute as
|
|
20552
|
+
import { isAbsolute as isAbsolute4 } from "node:path";
|
|
20652
20553
|
async function pluginWorkspaceRoot(directory) {
|
|
20653
|
-
requireThat(
|
|
20554
|
+
requireThat(isAbsolute4(directory), "\u63D2\u4EF6\u5DE5\u4F5C\u533A\u9700\u8981\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20654
20555
|
const root = await realpath5(directory);
|
|
20655
20556
|
requireThat((await stat5(root)).isDirectory(), "\u63D2\u4EF6\u5DE5\u4F5C\u533A\u9700\u8981\u76EE\u5F55\u3002");
|
|
20656
20557
|
return root;
|
|
@@ -20661,12 +20562,9 @@ function parsePromptEvent(value) {
|
|
|
20661
20562
|
if (name !== "Stop" && name !== "UserPromptSubmit" && name !== "SessionStart") return { kind: "ignore" };
|
|
20662
20563
|
if (typeof value.agent_id === "string") return { kind: "ignore" };
|
|
20663
20564
|
requireThat(typeof value.cwd === "string", "\u63D2\u4EF6 hook \u7F3A\u5C11\u5DE5\u4F5C\u76EE\u5F55\u3002");
|
|
20664
|
-
if (name
|
|
20665
|
-
if (
|
|
20666
|
-
|
|
20667
|
-
return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
|
|
20668
|
-
}
|
|
20669
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
20565
|
+
if (name !== "SessionStart") return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
20566
|
+
if (value.source === "resume" || value.source === "compact") return { kind: "ignore" };
|
|
20567
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
|
|
20670
20568
|
}
|
|
20671
20569
|
var promptHooks = {
|
|
20672
20570
|
async extractHistory(event) {
|
|
@@ -20712,7 +20610,7 @@ var promptHooks = {
|
|
|
20712
20610
|
};
|
|
20713
20611
|
|
|
20714
20612
|
// src/integrations/hosts/claude/adapter.ts
|
|
20715
|
-
var supportedEvents2 = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
20613
|
+
var supportedEvents2 = ["SessionStart", "UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
20716
20614
|
var boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
|
|
20717
20615
|
async function claudeWorkspaceRoot(cwd, projectDirectory = boundWorkspaceRoot()) {
|
|
20718
20616
|
return pluginWorkspaceRoot(projectDirectory || cwd);
|
|
@@ -20721,7 +20619,6 @@ var claudeAdapter = {
|
|
|
20721
20619
|
host: "claude",
|
|
20722
20620
|
nativeRootAgents: false,
|
|
20723
20621
|
nativeWorkspaceSkills: false,
|
|
20724
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
20725
20622
|
initCommandHint: "/personal-bot:pbot init",
|
|
20726
20623
|
usage: "\u7528\u6CD5\uFF1Anode <\u63D2\u4EF6\u76EE\u5F55>/lib/claude.js init|status",
|
|
20727
20624
|
boundWorkspaceRoot,
|
|
@@ -20814,7 +20711,7 @@ init_json();
|
|
|
20814
20711
|
init_validation();
|
|
20815
20712
|
init_atomic_json();
|
|
20816
20713
|
import { mkdir as mkdir3, readFile as readFile7 } from "node:fs/promises";
|
|
20817
|
-
import { dirname as dirname7, join as
|
|
20714
|
+
import { dirname as dirname7, join as join18, resolve as resolve9 } from "node:path";
|
|
20818
20715
|
var serverNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
20819
20716
|
var reservedServerNames = /* @__PURE__ */ new Set(["pbot"]);
|
|
20820
20717
|
var stdioKeys = /* @__PURE__ */ new Set(["command", "args", "env", "cwd", "description", "timeout", "enabled"]);
|
|
@@ -20920,7 +20817,7 @@ function validateMcpFile(value) {
|
|
|
20920
20817
|
return { ...value, mcpServers: servers };
|
|
20921
20818
|
}
|
|
20922
20819
|
function workspaceMcpPath(root) {
|
|
20923
|
-
return
|
|
20820
|
+
return join18(root, ".pbot", "mcp.json");
|
|
20924
20821
|
}
|
|
20925
20822
|
async function readWorkspaceMcpConfig(root) {
|
|
20926
20823
|
const path = workspaceMcpPath(root);
|
|
@@ -20967,9 +20864,9 @@ async function removeWorkspaceMcpServer(root, name) {
|
|
|
20967
20864
|
}
|
|
20968
20865
|
|
|
20969
20866
|
// src/extension/cli/commands/mcp.ts
|
|
20970
|
-
var mcpUsage = "\u7528\u6CD5\uFF1A\n pbot mcp\n pbot mcp list [--workspace <\u76EE\u5F55>] [--json]\n pbot mcp add <name> --url <url> [--header K=V]... [--description <\u8BF4\u660E>] [--timeout <\u79D2>] [--disabled] [--workspace <\u76EE\u5F55>]\n pbot mcp add <name> [--env K=V]... [--cwd <\u76EE\u5F55>] [--description <\u8BF4\u660E>] [--timeout <\u79D2>] [--disabled] [--workspace <\u76EE\u5F55>] -- <command> [args...]\n pbot mcp remove <name> [--workspace <\u76EE\u5F55>]\n\n\
|
|
20867
|
+
var mcpUsage = "\u7528\u6CD5\uFF1A\n pbot mcp\n pbot mcp list [--workspace <\u76EE\u5F55>] [--json]\n pbot mcp add <name> --url <url> [--header K=V]... [--description <\u8BF4\u660E>] [--timeout <\u79D2>] [--disabled] [--workspace <\u76EE\u5F55>]\n pbot mcp add <name> [--env K=V]... [--cwd <\u76EE\u5F55>] [--description <\u8BF4\u660E>] [--timeout <\u79D2>] [--disabled] [--workspace <\u76EE\u5F55>] -- <command> [args...]\n pbot mcp remove <name> [--workspace <\u76EE\u5F55>]\n\n\u4E0D\u5E26\u5B50\u547D\u4EE4\u65F6\u542F\u52A8 stdio MCP \u670D\u52A1\u3002\u7528 list\u3001add\u3001remove \u7BA1\u7406\u5DE5\u4F5C\u533A\u7684 .pbot/mcp.json\u3002";
|
|
20971
20868
|
async function runMcpServer() {
|
|
20972
|
-
const entry =
|
|
20869
|
+
const entry = join19(packageRoot, "lib/extension/mcp.js");
|
|
20973
20870
|
if (!existsSync2(entry)) {
|
|
20974
20871
|
console.error("\u7F3A\u5C11 MCP \u6784\u5EFA\u4EA7\u7269\uFF1A" + entry + "\u3002\u8BF7\u5148\u8FD0\u884C npm run build\u3002");
|
|
20975
20872
|
return 1;
|
|
@@ -21123,14 +21020,14 @@ init_validation();
|
|
|
21123
21020
|
|
|
21124
21021
|
// src/extension/hosts/plugin-runtime.ts
|
|
21125
21022
|
init_paths();
|
|
21126
|
-
import { join as
|
|
21023
|
+
import { join as join23 } from "node:path";
|
|
21127
21024
|
init_validation();
|
|
21128
21025
|
|
|
21129
21026
|
// src/integrations/agent-resources.ts
|
|
21130
21027
|
init_paths();
|
|
21131
21028
|
init_validation();
|
|
21132
21029
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
21133
|
-
import { join as
|
|
21030
|
+
import { join as join20 } from "node:path";
|
|
21134
21031
|
async function readOptionalFile(path) {
|
|
21135
21032
|
try {
|
|
21136
21033
|
return await readFile8(path, "utf8");
|
|
@@ -21140,14 +21037,14 @@ async function readOptionalFile(path) {
|
|
|
21140
21037
|
}
|
|
21141
21038
|
}
|
|
21142
21039
|
async function readLocalRole(agent, root) {
|
|
21143
|
-
const local = await readOptionalFile(
|
|
21040
|
+
const local = await readOptionalFile(join20(root, "agents", agent + ".md"));
|
|
21144
21041
|
return local.trim() ? "\u5DE5\u4F5C\u533A\u804C\u8D23\u8865\u5145\uFF1A\n" + local : "";
|
|
21145
21042
|
}
|
|
21146
21043
|
async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md") {
|
|
21147
21044
|
requireThat(agent === "coordinator" || agent === "general-purpose", "\u672A\u77E5\u804C\u8D23\u3002");
|
|
21148
|
-
let text = await readFile8(
|
|
21149
|
-
if (agent === "coordinator") {
|
|
21150
|
-
text += "\n\n" + await readFile8(
|
|
21045
|
+
let text = await readFile8(join20(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
21046
|
+
if (agent === "coordinator" && coordinatorPrompt) {
|
|
21047
|
+
text += "\n\n" + await readFile8(join20(resourceRoot, "prompts", coordinatorPrompt), "utf8");
|
|
21151
21048
|
}
|
|
21152
21049
|
const local = await readLocalRole(agent, root);
|
|
21153
21050
|
if (local) text += "\n\n" + local;
|
|
@@ -21157,7 +21054,7 @@ async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md
|
|
|
21157
21054
|
function formatWorkspaceSkills(skills) {
|
|
21158
21055
|
if (!skills.length) return "";
|
|
21159
21056
|
const lines = skills.map((skill) => `- **${skill.name}**\uFF08\`${skill.path}\`\uFF09\uFF1A${skill.description}`);
|
|
21160
|
-
return "## \
|
|
21057
|
+
return "## \u6309\u9700\u8BFB\u53D6\u7684\u6280\u80FD\n\n" + lines.join("\n");
|
|
21161
21058
|
}
|
|
21162
21059
|
async function loadWorkspaceContext(options) {
|
|
21163
21060
|
const {
|
|
@@ -21172,12 +21069,12 @@ async function loadWorkspaceContext(options) {
|
|
|
21172
21069
|
notices = []
|
|
21173
21070
|
} = options;
|
|
21174
21071
|
const [workspace, roleText, rootAgents] = includePrompts ? await Promise.all([
|
|
21175
|
-
readFile8(
|
|
21072
|
+
readFile8(join20(resourceRoot, "prompts/workspace.md"), "utf8"),
|
|
21176
21073
|
localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
|
|
21177
|
-
includeRootAgents ? readOptionalFile(
|
|
21074
|
+
includeRootAgents ? readOptionalFile(join20(root, "AGENTS.md")) : Promise.resolve("")
|
|
21178
21075
|
]) : ["", "", ""];
|
|
21179
21076
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
21180
|
-
const noticesSection = notices.length ? "## \
|
|
21077
|
+
const noticesSection = notices.length ? "## \u7EF4\u62A4\u63D0\u9192\n\n\u544A\u77E5\u7528\u6237\uFF0C\u6309\u7528\u6237\u8981\u6C42\u6267\u884C\u3002\n\n" + notices.map((item) => `- ${item}`).join("\n") : "";
|
|
21181
21078
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
21182
21079
|
const text = [
|
|
21183
21080
|
workspace,
|
|
@@ -21287,7 +21184,7 @@ init_validation();
|
|
|
21287
21184
|
init_paths();
|
|
21288
21185
|
init_workspace_config2();
|
|
21289
21186
|
import { lstat as lstat2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
21290
|
-
import { join as
|
|
21187
|
+
import { join as join21 } from "node:path";
|
|
21291
21188
|
async function initializeWorkspace(root) {
|
|
21292
21189
|
const configuration = await readWorkspaceConfig(root);
|
|
21293
21190
|
if (configuration.error) throw new Error(configuration.error);
|
|
@@ -21297,22 +21194,22 @@ async function initializeWorkspace(root) {
|
|
|
21297
21194
|
var directories = ["areas", "projects", "knowledge", "providers", "scratch", "agents"];
|
|
21298
21195
|
async function prepareWorkspace(root) {
|
|
21299
21196
|
for (const part of directories) {
|
|
21300
|
-
const path =
|
|
21197
|
+
const path = join21(root, part);
|
|
21301
21198
|
await mkdir4(path, { mode: 448 }).catch((error) => {
|
|
21302
21199
|
if (error.code !== "EEXIST") throw error;
|
|
21303
21200
|
});
|
|
21304
21201
|
const entry = await lstat2(path);
|
|
21305
21202
|
requireThat(entry.isDirectory() && !entry.isSymbolicLink(), "\u5DE5\u4F5C\u533A\u76EE\u5F55\u4E0D\u80FD\u4F7F\u7528\u7B26\u53F7\u94FE\u63A5\uFF1A" + path);
|
|
21306
21203
|
}
|
|
21307
|
-
const agents = await readFile9(
|
|
21308
|
-
await writeFile2(
|
|
21204
|
+
const agents = await readFile9(join21(resourceRoot, "templates/workspace-agents.md"), "utf8");
|
|
21205
|
+
await writeFile2(join21(root, "AGENTS.md"), agents, { flag: "wx" }).catch((error) => {
|
|
21309
21206
|
if (error.code !== "EEXIST") throw error;
|
|
21310
21207
|
});
|
|
21311
21208
|
}
|
|
21312
21209
|
|
|
21313
21210
|
// src/services/workspace/workspace-skills.ts
|
|
21314
21211
|
import { readdir, readFile as readFile10 } from "node:fs/promises";
|
|
21315
|
-
import { join as
|
|
21212
|
+
import { join as join22 } from "node:path";
|
|
21316
21213
|
function unquoteYaml(value) {
|
|
21317
21214
|
const trimmed = value.trim();
|
|
21318
21215
|
if (trimmed.length >= 2 && (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
@@ -21360,7 +21257,7 @@ function parseSkillFrontmatter(content) {
|
|
|
21360
21257
|
};
|
|
21361
21258
|
}
|
|
21362
21259
|
async function discoverWorkspaceSkills(root) {
|
|
21363
|
-
return discoverSkills(
|
|
21260
|
+
return discoverSkills(join22(root, ".agents", "skills"), ".agents/skills");
|
|
21364
21261
|
}
|
|
21365
21262
|
async function discoverSkills(skillsDir, indexPath) {
|
|
21366
21263
|
let entries;
|
|
@@ -21373,7 +21270,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21373
21270
|
const results = [];
|
|
21374
21271
|
for (const entry of entries) {
|
|
21375
21272
|
if (entry.name.startsWith(".") || !entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
21376
|
-
const filePath =
|
|
21273
|
+
const filePath = join22(skillsDir, entry.name, "SKILL.md");
|
|
21377
21274
|
let content;
|
|
21378
21275
|
try {
|
|
21379
21276
|
content = await readFile10(filePath, "utf8");
|
|
@@ -21385,7 +21282,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21385
21282
|
results.push({
|
|
21386
21283
|
name: meta.name,
|
|
21387
21284
|
description: meta.description,
|
|
21388
|
-
path:
|
|
21285
|
+
path: join22(indexPath, entry.name, "SKILL.md")
|
|
21389
21286
|
});
|
|
21390
21287
|
}
|
|
21391
21288
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -21402,7 +21299,6 @@ async function pluginCommand(adapter, args, cwd) {
|
|
|
21402
21299
|
requireThat(["init", "status"].includes(action), adapter.usage);
|
|
21403
21300
|
if (action === "init") {
|
|
21404
21301
|
await initializeWorkspace(root);
|
|
21405
|
-
bindWorkspacePlugin(root, adapter.host, process.env.PBOT_PLUGIN_MANIFEST || process.env.PBOT_PLUGIN_VERSION);
|
|
21406
21302
|
}
|
|
21407
21303
|
const configuration = await readWorkspaceConfig(root);
|
|
21408
21304
|
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
|
|
@@ -21436,7 +21332,6 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21436
21332
|
return adapter.formatPass(payload);
|
|
21437
21333
|
}
|
|
21438
21334
|
if (!configuration.enabled) return adapter.formatPass(payload);
|
|
21439
|
-
if (event.kind === "inject-context") bindWorkspacePlugin(root, adapter.host, process.env.PBOT_PLUGIN_MANIFEST || process.env.PBOT_PLUGIN_VERSION);
|
|
21440
21335
|
if (features.history && adapter.extractHistory) {
|
|
21441
21336
|
try {
|
|
21442
21337
|
const capture = await adapter.extractHistory(event);
|
|
@@ -21449,23 +21344,16 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21449
21344
|
const includeSkills = features.skills && !event.noticesOnly;
|
|
21450
21345
|
const workspaceSkills = includeSkills && !adapter.nativeWorkspaceSkills ? await discoverWorkspaceSkills(root) : [];
|
|
21451
21346
|
if (includeSkills && adapter.indexBundledSkills) {
|
|
21452
|
-
const directory =
|
|
21347
|
+
const directory = join23(resourceRoot, "skills");
|
|
21453
21348
|
workspaceSkills.push(...await discoverSkills(directory, directory));
|
|
21454
21349
|
}
|
|
21455
21350
|
const notices = event.isSessionStart && features.history ? [...historyStartupNotices(root)] : [];
|
|
21456
|
-
if (event.isSessionStart) {
|
|
21457
|
-
const drift = workspacePluginDrift(workspacePluginReleases(root));
|
|
21458
|
-
if (drift.outOfSync) {
|
|
21459
|
-
const summary = Object.entries(drift.versions).map(([host, version]) => `${host}=${version}`).join(", ");
|
|
21460
|
-
notices.push(`\u68C0\u6D4B\u5230\u5F53\u524D\u5DE5\u4F5C\u533A\u5404\u5BBF\u4E3B Personal Bot \u63D2\u4EF6\u7248\u672C\u4E0D\u4E00\u81F4\uFF08${summary}\uFF09\uFF0C\u53EF\u5728\u7EC8\u7AEF\u8FD0\u884C pbot upgrade \u7EDF\u4E00\u5347\u7EA7\u3002`);
|
|
21461
|
-
}
|
|
21462
|
-
}
|
|
21463
21351
|
if (!includePrompts && !workspaceSkills.length && !notices.length) return adapter.formatPass(payload);
|
|
21464
21352
|
const context = await loadWorkspaceContext({
|
|
21465
21353
|
host: adapter.host,
|
|
21466
21354
|
root,
|
|
21467
21355
|
role: event.role,
|
|
21468
|
-
|
|
21356
|
+
coordinatorPrompt: adapter.coordinatorPrompt ?? (features.history ? "plugin-coordinator.md" : null),
|
|
21469
21357
|
includePrompts,
|
|
21470
21358
|
includeRootAgents: includePrompts && !adapter.nativeRootAgents,
|
|
21471
21359
|
...event.localRoleOnly ? { localRoleOnly: true } : {},
|
|
@@ -21507,10 +21395,7 @@ var pluginCommand2 = {
|
|
|
21507
21395
|
};
|
|
21508
21396
|
|
|
21509
21397
|
// src/extension/cli/commands/upgrade.ts
|
|
21510
|
-
|
|
21511
|
-
init_json();
|
|
21512
|
-
import { readFile as readFile15 } from "node:fs/promises";
|
|
21513
|
-
import { join as join29 } from "node:path";
|
|
21398
|
+
import { join as join28 } from "node:path";
|
|
21514
21399
|
|
|
21515
21400
|
// src/common/package-source.ts
|
|
21516
21401
|
var import_semver5 = __toESM(require_semver2(), 1);
|
|
@@ -21535,7 +21420,7 @@ init_validation();
|
|
|
21535
21420
|
var import_semver6 = __toESM(require_semver2(), 1);
|
|
21536
21421
|
init_json();
|
|
21537
21422
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
21538
|
-
import { join as
|
|
21423
|
+
import { join as join24 } from "node:path";
|
|
21539
21424
|
async function readManifestVersion4(path) {
|
|
21540
21425
|
try {
|
|
21541
21426
|
const data = JSON.parse(await readFile11(path, "utf8"));
|
|
@@ -21545,26 +21430,67 @@ async function readManifestVersion4(path) {
|
|
|
21545
21430
|
throw error;
|
|
21546
21431
|
}
|
|
21547
21432
|
}
|
|
21433
|
+
function parsePluginList(raw) {
|
|
21434
|
+
const parsed = JSON.parse(raw);
|
|
21435
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21436
|
+
const entries = [];
|
|
21437
|
+
for (const item of items) {
|
|
21438
|
+
if (!object(item) || typeof item.name !== "string") continue;
|
|
21439
|
+
entries.push({
|
|
21440
|
+
name: item.name,
|
|
21441
|
+
...typeof item.version === "string" ? { version: item.version } : {}
|
|
21442
|
+
});
|
|
21443
|
+
}
|
|
21444
|
+
return entries;
|
|
21445
|
+
}
|
|
21548
21446
|
var antigravityUpgrader = {
|
|
21549
21447
|
host: "antigravity",
|
|
21550
21448
|
async upgrade(context) {
|
|
21551
|
-
|
|
21449
|
+
const agy = context.env.PBOT_AGY_COMMAND || await context.findExecutable("agy");
|
|
21450
|
+
if (!agy) {
|
|
21451
|
+
return {
|
|
21452
|
+
host: this.host,
|
|
21453
|
+
state: "skipped",
|
|
21454
|
+
detail: "\u672A\u627E\u5230 Antigravity CLI\uFF08agy\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21455
|
+
};
|
|
21456
|
+
}
|
|
21457
|
+
let entries;
|
|
21458
|
+
try {
|
|
21459
|
+
const raw = await context.run(agy, ["plugin", "list", "--json"], context.workspace);
|
|
21460
|
+
entries = parsePluginList(raw);
|
|
21461
|
+
} catch (error) {
|
|
21462
|
+
return {
|
|
21463
|
+
host: this.host,
|
|
21464
|
+
state: "failed",
|
|
21465
|
+
detail: `\u67E5\u8BE2 Antigravity \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21466
|
+
};
|
|
21467
|
+
}
|
|
21468
|
+
const entry = entries.find((item) => item.name === "personal-bot");
|
|
21469
|
+
if (!entry) {
|
|
21470
|
+
return {
|
|
21471
|
+
host: this.host,
|
|
21472
|
+
state: "skipped",
|
|
21473
|
+
detail: "\u672A\u5728 Antigravity \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21474
|
+
};
|
|
21475
|
+
}
|
|
21476
|
+
const installedVersion = entry.version;
|
|
21477
|
+
if (installedVersion && (0, import_semver6.valid)(installedVersion) && (0, import_semver6.gte)(installedVersion, context.targetVersion)) {
|
|
21552
21478
|
return {
|
|
21553
21479
|
host: this.host,
|
|
21554
21480
|
state: "up-to-date",
|
|
21555
|
-
previousVersion:
|
|
21556
|
-
version:
|
|
21481
|
+
previousVersion: installedVersion,
|
|
21482
|
+
version: installedVersion,
|
|
21557
21483
|
scope: "user",
|
|
21558
21484
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21559
21485
|
};
|
|
21560
21486
|
}
|
|
21561
|
-
const pluginDir =
|
|
21562
|
-
const bundledVersion = await readManifestVersion4(
|
|
21487
|
+
const pluginDir = join24(context.packageRoot, "lib", "antigravity-plugin");
|
|
21488
|
+
const bundledVersion = await readManifestVersion4(join24(pluginDir, "plugin.json"));
|
|
21563
21489
|
if (!bundledVersion) {
|
|
21564
21490
|
return {
|
|
21565
21491
|
host: this.host,
|
|
21566
21492
|
state: "skipped",
|
|
21567
|
-
...
|
|
21493
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21568
21494
|
detail: `\u7F3A\u5C11 Antigravity \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}`
|
|
21569
21495
|
};
|
|
21570
21496
|
}
|
|
@@ -21572,24 +21498,15 @@ var antigravityUpgrader = {
|
|
|
21572
21498
|
return {
|
|
21573
21499
|
host: this.host,
|
|
21574
21500
|
state: "skipped",
|
|
21575
|
-
...
|
|
21501
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21576
21502
|
detail: `\u5F53\u524D\u672C\u5730\u5305\u4EA7\u7269\u7248\u672C\u4E3A ${bundledVersion}\uFF0C\u4F4E\u4E8E\u76EE\u6807\u7248\u672C ${context.targetVersion}\uFF1B\u8BF7\u5148\u66F4\u65B0\u5168\u5C40 personal-bot \u5305\u3002`
|
|
21577
21503
|
};
|
|
21578
21504
|
}
|
|
21579
|
-
const agy = context.env.PBOT_AGY_COMMAND || await context.findExecutable("agy");
|
|
21580
|
-
if (!agy) {
|
|
21581
|
-
return {
|
|
21582
|
-
host: this.host,
|
|
21583
|
-
state: "skipped",
|
|
21584
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21585
|
-
detail: "\u672A\u627E\u5230 Antigravity CLI\uFF08agy\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21586
|
-
};
|
|
21587
|
-
}
|
|
21588
21505
|
await context.run(agy, ["plugin", "install", pluginDir], context.workspace);
|
|
21589
21506
|
return {
|
|
21590
21507
|
host: this.host,
|
|
21591
21508
|
state: "updated",
|
|
21592
|
-
...
|
|
21509
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21593
21510
|
version: bundledVersion,
|
|
21594
21511
|
scope: "user",
|
|
21595
21512
|
detail: `\u5DF2\u901A\u8FC7 agy plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
@@ -21602,7 +21519,7 @@ var antigravityUpgrader = {
|
|
|
21602
21519
|
var import_semver7 = __toESM(require_semver2(), 1);
|
|
21603
21520
|
init_json();
|
|
21604
21521
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
21605
|
-
function
|
|
21522
|
+
function parsePluginList2(raw) {
|
|
21606
21523
|
const parsed = JSON.parse(raw);
|
|
21607
21524
|
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21608
21525
|
const entries = [];
|
|
@@ -21650,19 +21567,17 @@ var claudeUpgrader = {
|
|
|
21650
21567
|
return {
|
|
21651
21568
|
host: this.host,
|
|
21652
21569
|
state: "skipped",
|
|
21653
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21654
21570
|
detail: "\u672A\u627E\u5230 Claude Code CLI\uFF08claude\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21655
21571
|
};
|
|
21656
21572
|
}
|
|
21657
21573
|
let entries;
|
|
21658
21574
|
try {
|
|
21659
21575
|
const raw = await context.run(claude, ["plugin", "list", "--json"], context.workspace);
|
|
21660
|
-
entries =
|
|
21576
|
+
entries = parsePluginList2(raw);
|
|
21661
21577
|
} catch (error) {
|
|
21662
21578
|
return {
|
|
21663
21579
|
host: this.host,
|
|
21664
21580
|
state: "failed",
|
|
21665
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21666
21581
|
detail: `\u67E5\u8BE2 Claude \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21667
21582
|
};
|
|
21668
21583
|
}
|
|
@@ -21671,11 +21586,10 @@ var claudeUpgrader = {
|
|
|
21671
21586
|
return {
|
|
21672
21587
|
host: this.host,
|
|
21673
21588
|
state: "skipped",
|
|
21674
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21675
21589
|
detail: "\u672A\u5728 Claude \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF08\u53EF\u80FD\u901A\u8FC7 --plugin-dir \u672C\u5730\u52A0\u8F7D\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21676
21590
|
};
|
|
21677
21591
|
}
|
|
21678
|
-
const installedVersion = entry.version
|
|
21592
|
+
const installedVersion = entry.version;
|
|
21679
21593
|
const scope = entry.scope ?? "user";
|
|
21680
21594
|
if (installedVersion && (0, import_semver7.valid)(installedVersion) && (0, import_semver7.gte)(installedVersion, context.targetVersion)) {
|
|
21681
21595
|
return {
|
|
@@ -21714,7 +21628,7 @@ var claudeUpgrader = {
|
|
|
21714
21628
|
var import_semver8 = __toESM(require_semver2(), 1);
|
|
21715
21629
|
init_json();
|
|
21716
21630
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
21717
|
-
import { join as
|
|
21631
|
+
import { join as join25 } from "node:path";
|
|
21718
21632
|
async function readManifestVersion5(path) {
|
|
21719
21633
|
try {
|
|
21720
21634
|
const data = JSON.parse(await readFile12(path, "utf8"));
|
|
@@ -21724,26 +21638,82 @@ async function readManifestVersion5(path) {
|
|
|
21724
21638
|
throw error;
|
|
21725
21639
|
}
|
|
21726
21640
|
}
|
|
21641
|
+
function parsePluginList3(raw) {
|
|
21642
|
+
const parsed = JSON.parse(raw);
|
|
21643
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.installed) ? parsed.installed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21644
|
+
const entries = [];
|
|
21645
|
+
for (const item of items) {
|
|
21646
|
+
if (!object(item)) continue;
|
|
21647
|
+
const id = typeof item.pluginId === "string" ? item.pluginId : typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : void 0;
|
|
21648
|
+
if (!id) continue;
|
|
21649
|
+
entries.push({
|
|
21650
|
+
id,
|
|
21651
|
+
...typeof item.name === "string" ? { name: item.name } : {},
|
|
21652
|
+
...typeof item.version === "string" ? { version: item.version } : {},
|
|
21653
|
+
...typeof item.installed === "boolean" ? { installed: item.installed } : {}
|
|
21654
|
+
});
|
|
21655
|
+
}
|
|
21656
|
+
return entries;
|
|
21657
|
+
}
|
|
21658
|
+
function isMissingMarketplaceError(error) {
|
|
21659
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
21660
|
+
return /marketplace.*(not found|unknown|does not exist|not configured)|unknown marketplace/i.test(message);
|
|
21661
|
+
}
|
|
21727
21662
|
var codexUpgrader = {
|
|
21728
21663
|
host: "codex",
|
|
21729
21664
|
async upgrade(context) {
|
|
21730
|
-
|
|
21665
|
+
const codex = context.env.PBOT_CODEX_COMMAND || await context.findExecutable("codex");
|
|
21666
|
+
if (!codex) {
|
|
21667
|
+
return {
|
|
21668
|
+
host: this.host,
|
|
21669
|
+
state: "skipped",
|
|
21670
|
+
detail: "\u672A\u627E\u5230 Codex CLI\uFF08codex\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21671
|
+
};
|
|
21672
|
+
}
|
|
21673
|
+
let entries;
|
|
21674
|
+
try {
|
|
21675
|
+
const raw = await context.run(codex, ["plugin", "list", "-m", "pbot-local", "--json"], context.workspace);
|
|
21676
|
+
entries = parsePluginList3(raw);
|
|
21677
|
+
} catch (error) {
|
|
21678
|
+
if (isMissingMarketplaceError(error)) {
|
|
21679
|
+
return {
|
|
21680
|
+
host: this.host,
|
|
21681
|
+
state: "skipped",
|
|
21682
|
+
detail: "\u672A\u5728 Codex \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21683
|
+
};
|
|
21684
|
+
}
|
|
21685
|
+
return {
|
|
21686
|
+
host: this.host,
|
|
21687
|
+
state: "failed",
|
|
21688
|
+
detail: `\u67E5\u8BE2 Codex \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21689
|
+
};
|
|
21690
|
+
}
|
|
21691
|
+
const entry = entries.find((item) => item.installed !== false && (item.name === "personal-bot" || item.id === "personal-bot" || item.id.startsWith("personal-bot@")));
|
|
21692
|
+
if (!entry) {
|
|
21693
|
+
return {
|
|
21694
|
+
host: this.host,
|
|
21695
|
+
state: "skipped",
|
|
21696
|
+
detail: "\u672A\u5728 Codex \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21697
|
+
};
|
|
21698
|
+
}
|
|
21699
|
+
const installedVersion = entry.version;
|
|
21700
|
+
if (installedVersion && (0, import_semver8.valid)(installedVersion) && (0, import_semver8.gte)(installedVersion, context.targetVersion)) {
|
|
21731
21701
|
return {
|
|
21732
21702
|
host: this.host,
|
|
21733
21703
|
state: "up-to-date",
|
|
21734
|
-
previousVersion:
|
|
21735
|
-
version:
|
|
21704
|
+
previousVersion: installedVersion,
|
|
21705
|
+
version: installedVersion,
|
|
21736
21706
|
scope: "user",
|
|
21737
21707
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21738
21708
|
};
|
|
21739
21709
|
}
|
|
21740
|
-
const marketplaceDir =
|
|
21741
|
-
const bundledVersion = await readManifestVersion5(
|
|
21710
|
+
const marketplaceDir = join25(context.packageRoot, "lib", "codex-marketplace");
|
|
21711
|
+
const bundledVersion = await readManifestVersion5(join25(marketplaceDir, "plugins", "personal-bot", ".codex-plugin", "plugin.json"));
|
|
21742
21712
|
if (!bundledVersion) {
|
|
21743
21713
|
return {
|
|
21744
21714
|
host: this.host,
|
|
21745
21715
|
state: "skipped",
|
|
21746
|
-
...
|
|
21716
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21747
21717
|
detail: `\u7F3A\u5C11 Codex \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${marketplaceDir}`
|
|
21748
21718
|
};
|
|
21749
21719
|
}
|
|
@@ -21751,19 +21721,10 @@ var codexUpgrader = {
|
|
|
21751
21721
|
return {
|
|
21752
21722
|
host: this.host,
|
|
21753
21723
|
state: "skipped",
|
|
21754
|
-
...
|
|
21724
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21755
21725
|
detail: `\u5F53\u524D\u672C\u5730\u5305\u4EA7\u7269\u7248\u672C\u4E3A ${bundledVersion}\uFF0C\u4F4E\u4E8E\u76EE\u6807\u7248\u672C ${context.targetVersion}\uFF1B\u8BF7\u5148\u66F4\u65B0\u5168\u5C40 personal-bot \u5305\u3002`
|
|
21756
21726
|
};
|
|
21757
21727
|
}
|
|
21758
|
-
const codex = context.env.PBOT_CODEX_COMMAND || await context.findExecutable("codex");
|
|
21759
|
-
if (!codex) {
|
|
21760
|
-
return {
|
|
21761
|
-
host: this.host,
|
|
21762
|
-
state: "skipped",
|
|
21763
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21764
|
-
detail: "\u672A\u627E\u5230 Codex CLI\uFF08codex\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21765
|
-
};
|
|
21766
|
-
}
|
|
21767
21728
|
try {
|
|
21768
21729
|
await context.run(codex, ["plugin", "marketplace", "add", marketplaceDir], context.workspace);
|
|
21769
21730
|
} catch {
|
|
@@ -21772,7 +21733,7 @@ var codexUpgrader = {
|
|
|
21772
21733
|
return {
|
|
21773
21734
|
host: this.host,
|
|
21774
21735
|
state: "updated",
|
|
21775
|
-
...
|
|
21736
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21776
21737
|
version: bundledVersion,
|
|
21777
21738
|
scope: "user",
|
|
21778
21739
|
detail: `\u5DF2\u901A\u8FC7 codex plugin add \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
@@ -21783,41 +21744,63 @@ var codexUpgrader = {
|
|
|
21783
21744
|
|
|
21784
21745
|
// src/integrations/installation/upgraders/dsh.ts
|
|
21785
21746
|
var import_semver9 = __toESM(require_semver2(), 1);
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
const
|
|
21789
|
-
|
|
21790
|
-
|
|
21747
|
+
init_json();
|
|
21748
|
+
function parseInstalledVersion(raw) {
|
|
21749
|
+
const trimmed = raw.trim();
|
|
21750
|
+
if (!trimmed) return void 0;
|
|
21751
|
+
const parsed = JSON.parse(trimmed);
|
|
21752
|
+
const items = Array.isArray(parsed) ? parsed : [parsed];
|
|
21753
|
+
for (const item of items) {
|
|
21754
|
+
if (!object(item)) continue;
|
|
21755
|
+
const deps = item.dependencies;
|
|
21756
|
+
if (!object(deps)) continue;
|
|
21757
|
+
const pkg = deps["personal-bot"];
|
|
21758
|
+
if (object(pkg) && typeof pkg.version === "string" && (0, import_semver9.valid)(pkg.version)) return pkg.version;
|
|
21759
|
+
}
|
|
21760
|
+
return void 0;
|
|
21791
21761
|
}
|
|
21792
21762
|
var dshUpgrader = {
|
|
21793
21763
|
host: "dsh",
|
|
21794
21764
|
async upgrade(context) {
|
|
21795
|
-
|
|
21765
|
+
const profile = context.options.dshProfile || "pbot";
|
|
21766
|
+
const scope = `profile:${profile}`;
|
|
21767
|
+
const dsh = context.env.PBOT_DSH_COMMAND || await context.findExecutable("dsh");
|
|
21768
|
+
if (!dsh) {
|
|
21796
21769
|
return {
|
|
21797
21770
|
host: this.host,
|
|
21798
|
-
state: "
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21771
|
+
state: "skipped",
|
|
21772
|
+
scope,
|
|
21773
|
+
detail: "\u672A\u627E\u5230 dsh CLI\uFF08dsh\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21802
21774
|
};
|
|
21803
21775
|
}
|
|
21804
|
-
|
|
21805
|
-
|
|
21776
|
+
let installedVersion;
|
|
21777
|
+
try {
|
|
21778
|
+
const raw = await context.run(dsh, ["plugin", "--profile", profile, "list", "personal-bot", "--json"], context.workspace);
|
|
21779
|
+
installedVersion = parseInstalledVersion(raw);
|
|
21780
|
+
} catch (error) {
|
|
21806
21781
|
return {
|
|
21807
21782
|
host: this.host,
|
|
21808
|
-
state: "
|
|
21809
|
-
|
|
21810
|
-
detail:
|
|
21783
|
+
state: "failed",
|
|
21784
|
+
scope,
|
|
21785
|
+
detail: `\u67E5\u8BE2 dsh profile "${profile}" \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21811
21786
|
};
|
|
21812
21787
|
}
|
|
21813
|
-
|
|
21814
|
-
if (!dsh) {
|
|
21788
|
+
if (!installedVersion) {
|
|
21815
21789
|
return {
|
|
21816
21790
|
host: this.host,
|
|
21817
21791
|
state: "skipped",
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
|
|
21792
|
+
scope,
|
|
21793
|
+
detail: `dsh profile "${profile}" \u4E2D\u672A\u5B89\u88C5 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002`
|
|
21794
|
+
};
|
|
21795
|
+
}
|
|
21796
|
+
if ((0, import_semver9.gte)(installedVersion, context.targetVersion)) {
|
|
21797
|
+
return {
|
|
21798
|
+
host: this.host,
|
|
21799
|
+
state: "up-to-date",
|
|
21800
|
+
previousVersion: installedVersion,
|
|
21801
|
+
version: installedVersion,
|
|
21802
|
+
scope,
|
|
21803
|
+
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21821
21804
|
};
|
|
21822
21805
|
}
|
|
21823
21806
|
try {
|
|
@@ -21826,17 +21809,17 @@ var dshUpgrader = {
|
|
|
21826
21809
|
return {
|
|
21827
21810
|
host: this.host,
|
|
21828
21811
|
state: "failed",
|
|
21829
|
-
|
|
21830
|
-
scope
|
|
21812
|
+
previousVersion: installedVersion,
|
|
21813
|
+
scope,
|
|
21831
21814
|
detail: `${error instanceof Error ? error.message : String(error)}\uFF08\u63D0\u793A\uFF1A\u66F4\u65B0 dsh \u63D2\u4EF6\u524D\u9700\u5148\u505C\u6B62\u5BF9\u5E94 profile \u7684 dsh \u670D\u52A1\uFF09`
|
|
21832
21815
|
};
|
|
21833
21816
|
}
|
|
21834
21817
|
return {
|
|
21835
21818
|
host: this.host,
|
|
21836
21819
|
state: "updated",
|
|
21837
|
-
|
|
21820
|
+
previousVersion: installedVersion,
|
|
21838
21821
|
version: context.targetVersion,
|
|
21839
|
-
scope
|
|
21822
|
+
scope,
|
|
21840
21823
|
detail: `\u5DF2\u66F4\u65B0 dsh profile "${profile}" \u4E2D\u7684 personal-bot\u3002`,
|
|
21841
21824
|
nextStep: `\u91CD\u65B0\u542F\u52A8 dsh --profile ${profile} \u4F7F\u65B0\u7248\u672C\u751F\u6548\u3002`
|
|
21842
21825
|
};
|
|
@@ -21847,14 +21830,14 @@ var dshUpgrader = {
|
|
|
21847
21830
|
var import_semver10 = __toESM(require_semver2(), 1);
|
|
21848
21831
|
init_json();
|
|
21849
21832
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
21850
|
-
import { join as
|
|
21833
|
+
import { join as join26 } from "node:path";
|
|
21851
21834
|
function packageSource(entry) {
|
|
21852
21835
|
if (typeof entry === "string") return entry;
|
|
21853
21836
|
if (object(entry) && typeof entry.source === "string") return entry.source;
|
|
21854
21837
|
return void 0;
|
|
21855
21838
|
}
|
|
21856
21839
|
async function hasCustomOnlySource(workspace) {
|
|
21857
|
-
const settingsPath =
|
|
21840
|
+
const settingsPath = join26(workspace, ".pi", "settings.json");
|
|
21858
21841
|
try {
|
|
21859
21842
|
const data = JSON.parse(await readFile13(settingsPath, "utf8"));
|
|
21860
21843
|
if (!object(data) || !Array.isArray(data.packages)) return false;
|
|
@@ -21868,7 +21851,7 @@ async function hasCustomOnlySource(workspace) {
|
|
|
21868
21851
|
}
|
|
21869
21852
|
}
|
|
21870
21853
|
async function readLocalPiVersion(workspace) {
|
|
21871
|
-
const manifestPath =
|
|
21854
|
+
const manifestPath = join26(workspace, ".pi", "npm", "node_modules", "personal-bot", "package.json");
|
|
21872
21855
|
try {
|
|
21873
21856
|
const data = JSON.parse(await readFile13(manifestPath, "utf8"));
|
|
21874
21857
|
return object(data) && data.name === "personal-bot" && typeof data.version === "string" && (0, import_semver10.valid)(data.version) ? data.version : void 0;
|
|
@@ -21880,24 +21863,31 @@ async function readLocalPiVersion(workspace) {
|
|
|
21880
21863
|
var piUpgrader = {
|
|
21881
21864
|
host: "pi",
|
|
21882
21865
|
async upgrade(context) {
|
|
21883
|
-
|
|
21884
|
-
if (current && (0, import_semver10.valid)(current) && (0, import_semver10.gte)(current, context.targetVersion)) {
|
|
21866
|
+
if (await hasCustomOnlySource(context.workspace)) {
|
|
21885
21867
|
return {
|
|
21886
21868
|
host: this.host,
|
|
21887
|
-
state: "
|
|
21888
|
-
previousVersion: current,
|
|
21889
|
-
version: current,
|
|
21869
|
+
state: "skipped",
|
|
21890
21870
|
scope: "local",
|
|
21891
|
-
detail: "\u5DF2\
|
|
21871
|
+
detail: "\u5DE5\u4F5C\u533A Pi \u914D\u7F6E\u4E2D\u7684 personal-bot \u4F7F\u7528\u975E npm \u81EA\u5B9A\u4E49\u6765\u6E90\uFF0C\u5DF2\u4FDD\u7559\u5F53\u524D\u914D\u7F6E\u3002"
|
|
21892
21872
|
};
|
|
21893
21873
|
}
|
|
21894
|
-
|
|
21874
|
+
const current = await readLocalPiVersion(context.workspace);
|
|
21875
|
+
if (!current) {
|
|
21895
21876
|
return {
|
|
21896
21877
|
host: this.host,
|
|
21897
21878
|
state: "skipped",
|
|
21898
|
-
...current ? { previousVersion: current } : {},
|
|
21899
21879
|
scope: "local",
|
|
21900
|
-
detail: "\u5DE5\u4F5C\u533A Pi \
|
|
21880
|
+
detail: "\u5F53\u524D\u5DE5\u4F5C\u533A\u672A\u901A\u8FC7 Pi \u5B89\u88C5 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21881
|
+
};
|
|
21882
|
+
}
|
|
21883
|
+
if ((0, import_semver10.gte)(current, context.targetVersion)) {
|
|
21884
|
+
return {
|
|
21885
|
+
host: this.host,
|
|
21886
|
+
state: "up-to-date",
|
|
21887
|
+
previousVersion: current,
|
|
21888
|
+
version: current,
|
|
21889
|
+
scope: "local",
|
|
21890
|
+
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21901
21891
|
};
|
|
21902
21892
|
}
|
|
21903
21893
|
const pi = context.env.PBOT_PI_COMMAND || await context.findExecutable("pi");
|
|
@@ -21905,7 +21895,7 @@ var piUpgrader = {
|
|
|
21905
21895
|
return {
|
|
21906
21896
|
host: this.host,
|
|
21907
21897
|
state: "skipped",
|
|
21908
|
-
|
|
21898
|
+
previousVersion: current,
|
|
21909
21899
|
scope: "local",
|
|
21910
21900
|
detail: "\u672A\u627E\u5230 Pi CLI\uFF08pi\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21911
21901
|
};
|
|
@@ -21915,7 +21905,7 @@ var piUpgrader = {
|
|
|
21915
21905
|
return {
|
|
21916
21906
|
host: this.host,
|
|
21917
21907
|
state: "updated",
|
|
21918
|
-
|
|
21908
|
+
previousVersion: current,
|
|
21919
21909
|
version: installed,
|
|
21920
21910
|
scope: "local",
|
|
21921
21911
|
detail: `\u5DF2\u901A\u8FC7 pi install --local \u66F4\u65B0\u5DE5\u4F5C\u533A personal-bot \u5230 ${installed}\u3002`,
|
|
@@ -21927,8 +21917,8 @@ var piUpgrader = {
|
|
|
21927
21917
|
// src/integrations/installation/upgraders/qoder.ts
|
|
21928
21918
|
var import_semver11 = __toESM(require_semver2(), 1);
|
|
21929
21919
|
init_json();
|
|
21930
|
-
import { readFile as readFile14 } from "node:fs/promises";
|
|
21931
|
-
import { join as
|
|
21920
|
+
import { readFile as readFile14, realpath as realpath7 } from "node:fs/promises";
|
|
21921
|
+
import { join as join27 } from "node:path";
|
|
21932
21922
|
async function readManifestVersion6(path) {
|
|
21933
21923
|
try {
|
|
21934
21924
|
const data = JSON.parse(await readFile14(path, "utf8"));
|
|
@@ -21938,26 +21928,97 @@ async function readManifestVersion6(path) {
|
|
|
21938
21928
|
throw error;
|
|
21939
21929
|
}
|
|
21940
21930
|
}
|
|
21931
|
+
function parsePluginList4(raw) {
|
|
21932
|
+
const parsed = JSON.parse(raw);
|
|
21933
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21934
|
+
const entries = [];
|
|
21935
|
+
for (const item of items) {
|
|
21936
|
+
if (!object(item)) continue;
|
|
21937
|
+
const id = typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : void 0;
|
|
21938
|
+
if (!id) continue;
|
|
21939
|
+
entries.push({
|
|
21940
|
+
id,
|
|
21941
|
+
...typeof item.name === "string" ? { name: item.name } : {},
|
|
21942
|
+
...typeof item.version === "string" ? { version: item.version } : {},
|
|
21943
|
+
...typeof item.scope === "string" ? { scope: item.scope } : {},
|
|
21944
|
+
...typeof item.projectPath === "string" ? { projectPath: item.projectPath } : {}
|
|
21945
|
+
});
|
|
21946
|
+
}
|
|
21947
|
+
return entries;
|
|
21948
|
+
}
|
|
21949
|
+
async function resolvePathSafe2(value) {
|
|
21950
|
+
try {
|
|
21951
|
+
return await realpath7(value);
|
|
21952
|
+
} catch {
|
|
21953
|
+
return value;
|
|
21954
|
+
}
|
|
21955
|
+
}
|
|
21956
|
+
async function selectMatchingEntry2(entries, workspace) {
|
|
21957
|
+
const canonicalWorkspace = await resolvePathSafe2(workspace);
|
|
21958
|
+
const candidates = entries.filter((entry) => entry.name === "personal-bot" || entry.id === "personal-bot" || entry.id.startsWith("personal-bot@"));
|
|
21959
|
+
if (!candidates.length) return void 0;
|
|
21960
|
+
const scopedMatches = [];
|
|
21961
|
+
for (const entry of candidates) {
|
|
21962
|
+
if (!entry.projectPath) {
|
|
21963
|
+
scopedMatches.push(entry);
|
|
21964
|
+
continue;
|
|
21965
|
+
}
|
|
21966
|
+
if (await resolvePathSafe2(entry.projectPath) === canonicalWorkspace) scopedMatches.push(entry);
|
|
21967
|
+
}
|
|
21968
|
+
const priority = /* @__PURE__ */ new Map([["local", 0], ["project", 1], ["user", 2]]);
|
|
21969
|
+
scopedMatches.sort((a, b) => (priority.get(a.scope ?? "") ?? 9) - (priority.get(b.scope ?? "") ?? 9));
|
|
21970
|
+
return scopedMatches[0];
|
|
21971
|
+
}
|
|
21941
21972
|
var qoderUpgrader = {
|
|
21942
21973
|
host: "qoder",
|
|
21943
21974
|
async upgrade(context) {
|
|
21944
|
-
|
|
21975
|
+
const qodercli = context.env.PBOT_QODER_COMMAND || await context.findExecutable("qodercli");
|
|
21976
|
+
if (!qodercli) {
|
|
21977
|
+
return {
|
|
21978
|
+
host: this.host,
|
|
21979
|
+
state: "skipped",
|
|
21980
|
+
detail: "\u672A\u627E\u5230 Qoder CLI\uFF08qodercli\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21981
|
+
};
|
|
21982
|
+
}
|
|
21983
|
+
let entries;
|
|
21984
|
+
try {
|
|
21985
|
+
const raw = await context.run(qodercli, ["plugin", "list", "--json"], context.workspace);
|
|
21986
|
+
entries = parsePluginList4(raw);
|
|
21987
|
+
} catch (error) {
|
|
21988
|
+
return {
|
|
21989
|
+
host: this.host,
|
|
21990
|
+
state: "failed",
|
|
21991
|
+
detail: `\u67E5\u8BE2 Qoder CLI \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21992
|
+
};
|
|
21993
|
+
}
|
|
21994
|
+
const entry = await selectMatchingEntry2(entries, context.workspace);
|
|
21995
|
+
if (!entry) {
|
|
21996
|
+
return {
|
|
21997
|
+
host: this.host,
|
|
21998
|
+
state: "skipped",
|
|
21999
|
+
detail: "\u672A\u5728 Qoder CLI \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
22000
|
+
};
|
|
22001
|
+
}
|
|
22002
|
+
const installedVersion = entry.version;
|
|
22003
|
+
const scope = entry.scope ?? "user";
|
|
22004
|
+
if (installedVersion && (0, import_semver11.valid)(installedVersion) && (0, import_semver11.gte)(installedVersion, context.targetVersion)) {
|
|
21945
22005
|
return {
|
|
21946
22006
|
host: this.host,
|
|
21947
22007
|
state: "up-to-date",
|
|
21948
|
-
previousVersion:
|
|
21949
|
-
version:
|
|
21950
|
-
scope
|
|
22008
|
+
previousVersion: installedVersion,
|
|
22009
|
+
version: installedVersion,
|
|
22010
|
+
scope,
|
|
21951
22011
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21952
22012
|
};
|
|
21953
22013
|
}
|
|
21954
|
-
const pluginDir =
|
|
21955
|
-
const bundledVersion = await readManifestVersion6(
|
|
22014
|
+
const pluginDir = join27(context.packageRoot, "lib", "qoder-plugin");
|
|
22015
|
+
const bundledVersion = await readManifestVersion6(join27(pluginDir, ".qoder-plugin", "plugin.json"));
|
|
21956
22016
|
if (!bundledVersion) {
|
|
21957
22017
|
return {
|
|
21958
22018
|
host: this.host,
|
|
21959
22019
|
state: "skipped",
|
|
21960
|
-
...
|
|
22020
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
22021
|
+
scope,
|
|
21961
22022
|
detail: `\u7F3A\u5C11 Qoder CLI \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}`
|
|
21962
22023
|
};
|
|
21963
22024
|
}
|
|
@@ -21965,27 +22026,19 @@ var qoderUpgrader = {
|
|
|
21965
22026
|
return {
|
|
21966
22027
|
host: this.host,
|
|
21967
22028
|
state: "skipped",
|
|
21968
|
-
...
|
|
22029
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
22030
|
+
scope,
|
|
21969
22031
|
detail: `\u5F53\u524D\u672C\u5730\u5305\u4EA7\u7269\u7248\u672C\u4E3A ${bundledVersion}\uFF0C\u4F4E\u4E8E\u76EE\u6807\u7248\u672C ${context.targetVersion}\uFF1B\u8BF7\u5148\u66F4\u65B0\u5168\u5C40 personal-bot \u5305\u3002`
|
|
21970
22032
|
};
|
|
21971
22033
|
}
|
|
21972
|
-
|
|
21973
|
-
if (!qodercli) {
|
|
21974
|
-
return {
|
|
21975
|
-
host: this.host,
|
|
21976
|
-
state: "skipped",
|
|
21977
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21978
|
-
detail: "\u672A\u627E\u5230 Qoder CLI\uFF08qodercli\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21979
|
-
};
|
|
21980
|
-
}
|
|
21981
|
-
await context.run(qodercli, ["plugin", "install", pluginDir], context.workspace);
|
|
22034
|
+
await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", scope], context.workspace);
|
|
21982
22035
|
return {
|
|
21983
22036
|
host: this.host,
|
|
21984
22037
|
state: "updated",
|
|
21985
|
-
...
|
|
22038
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21986
22039
|
version: bundledVersion,
|
|
21987
|
-
scope
|
|
21988
|
-
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
22040
|
+
scope,
|
|
22041
|
+
detail: `\u5DF2\u6309\u539F\u6709\u4F5C\u7528\u57DF\uFF08${scope}\uFF09\u901A\u8FC7 qodercli plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
21989
22042
|
nextStep: "\u91CD\u542F Qoder CLI \u4F1A\u8BDD\u4F7F\u65B0\u7248\u672C\u751F\u6548\u3002"
|
|
21990
22043
|
};
|
|
21991
22044
|
}
|
|
@@ -22021,11 +22074,12 @@ var hostUpgraders = new HostUpgraderRegistry([
|
|
|
22021
22074
|
dshUpgrader
|
|
22022
22075
|
]);
|
|
22023
22076
|
var getHostUpgrader = (host) => hostUpgraders.get(host);
|
|
22077
|
+
var listHostUpgraders = () => hostUpgraders.list();
|
|
22024
22078
|
|
|
22025
22079
|
// src/services/installation/upgrade-service.ts
|
|
22026
22080
|
var import_semver12 = __toESM(require_semver2(), 1);
|
|
22027
22081
|
init_validation();
|
|
22028
|
-
var upgradeUsage = "\u7528\u6CD5\uFF1Apbot upgrade|update [--workspace <\u76EE\u5F55>] [--version <MAJOR.MINOR.PATCH>] [--hosts <h1,h2>] [--dsh-profile <\u540D\u79F0>] [--json]\n\u5C06\u5168\u5C40 CLI \u4E0E\u5F53\u524D\u5DE5\u4F5C\u533A\u5DF2\
|
|
22082
|
+
var upgradeUsage = "\u7528\u6CD5\uFF1Apbot upgrade|update [--workspace <\u76EE\u5F55>] [--version <MAJOR.MINOR.PATCH>] [--hosts <h1,h2>] [--dsh-profile <\u540D\u79F0>] [--json]\n\u5C06\u5168\u5C40 CLI \u4E0E\u672C\u673A/\u5F53\u524D\u5DE5\u4F5C\u533A\u5DF2\u5B89\u88C5\u7684\u5404\u5BBF\u4E3B\u63D2\u4EF6\u7EDF\u4E00\u5347\u7EA7\u5230 npm \u6700\u65B0\u7A33\u5B9A\u7248\uFF08\u6216\u6307\u5B9A\u7248\u672C\uFF09\u3002";
|
|
22029
22083
|
function parseUpgradeArgs(args) {
|
|
22030
22084
|
let workspace;
|
|
22031
22085
|
let version;
|
|
@@ -22090,7 +22144,6 @@ async function executeWorkspaceUpgrade(input) {
|
|
|
22090
22144
|
result = {
|
|
22091
22145
|
host: target.host,
|
|
22092
22146
|
state: "skipped",
|
|
22093
|
-
...target.currentVersion ? { previousVersion: target.currentVersion } : {},
|
|
22094
22147
|
detail: "\u672A\u6CE8\u518C\u8BE5\u5BBF\u4E3B\u7684\u81EA\u52A8\u5347\u7EA7\u9002\u914D\u5668\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
22095
22148
|
};
|
|
22096
22149
|
} else {
|
|
@@ -22101,7 +22154,6 @@ async function executeWorkspaceUpgrade(input) {
|
|
|
22101
22154
|
result = {
|
|
22102
22155
|
host: target.host,
|
|
22103
22156
|
state: "failed",
|
|
22104
|
-
...target.currentVersion ? { previousVersion: target.currentVersion } : {},
|
|
22105
22157
|
detail: error instanceof Error ? error.message : String(error)
|
|
22106
22158
|
};
|
|
22107
22159
|
}
|
|
@@ -22136,31 +22188,9 @@ async function latestStableVersion(processes, cwd) {
|
|
|
22136
22188
|
if (typeof value.version !== "string") throw new Error("\u65E0\u6CD5\u53D6\u5F97 personal-bot \u7684\u6700\u65B0\u7248\u672C\u3002");
|
|
22137
22189
|
return checkStableVersion(value.version, value.engines?.node);
|
|
22138
22190
|
}
|
|
22139
|
-
|
|
22140
|
-
const
|
|
22141
|
-
|
|
22142
|
-
for (const [host, entry] of Object.entries(bindings)) {
|
|
22143
|
-
byHost.set(host, {
|
|
22144
|
-
host,
|
|
22145
|
-
currentVersion: entry.version,
|
|
22146
|
-
...entry.bindingPath ? { bindingPath: entry.bindingPath } : {}
|
|
22147
|
-
});
|
|
22148
|
-
}
|
|
22149
|
-
if (!byHost.has("pi")) {
|
|
22150
|
-
const localPiManifest = join29(workspace, ".pi", "npm", "node_modules", "personal-bot", "package.json");
|
|
22151
|
-
try {
|
|
22152
|
-
const manifest2 = JSON.parse(await readFile15(localPiManifest, "utf8"));
|
|
22153
|
-
if (object(manifest2) && manifest2.name === "personal-bot" && typeof manifest2.version === "string" && (0, import_semver13.valid)(manifest2.version)) {
|
|
22154
|
-
byHost.set("pi", { host: "pi", currentVersion: manifest2.version, bindingPath: localPiManifest });
|
|
22155
|
-
}
|
|
22156
|
-
} catch (error) {
|
|
22157
|
-
if (error.code !== "ENOENT") throw error;
|
|
22158
|
-
}
|
|
22159
|
-
}
|
|
22160
|
-
if (requestedHosts) {
|
|
22161
|
-
return requestedHosts.map((host) => byHost.get(host) ?? { host });
|
|
22162
|
-
}
|
|
22163
|
-
return [...byHost.values()].sort((a, b) => a.host.localeCompare(b.host));
|
|
22191
|
+
function resolveUpgradeTargets(requestedHosts) {
|
|
22192
|
+
const hosts = requestedHosts ?? listHostUpgraders();
|
|
22193
|
+
return hosts.map((host) => ({ host }));
|
|
22164
22194
|
}
|
|
22165
22195
|
function formatLine2(result) {
|
|
22166
22196
|
const transition = result.previousVersion && result.version && result.previousVersion !== result.version ? `${result.previousVersion} \u2192 ${result.version}` : result.version ?? result.previousVersion ?? "";
|
|
@@ -22174,7 +22204,7 @@ function printHumanSummary2(summary) {
|
|
|
22174
22204
|
console.log(`\u76EE\u6807\u7248\u672C\uFF1A${summary.targetVersion}`);
|
|
22175
22205
|
console.log(`[${summary.cli.state}] cli ${summary.cli.previousVersion} \u2192 ${summary.cli.version}: ${summary.cli.detail}`);
|
|
22176
22206
|
if (!summary.results.length) {
|
|
22177
|
-
console.log("\
|
|
22207
|
+
console.log("\u672A\u6CE8\u518C\u4EFB\u4F55\u5BBF\u4E3B\u5347\u7EA7\u9002\u914D\u5668\u3002");
|
|
22178
22208
|
return;
|
|
22179
22209
|
}
|
|
22180
22210
|
for (const result of summary.results) console.log(formatLine2(result));
|
|
@@ -22182,7 +22212,7 @@ function printHumanSummary2(summary) {
|
|
|
22182
22212
|
var upgradeCommand = {
|
|
22183
22213
|
name: "upgrade",
|
|
22184
22214
|
aliases: ["update"],
|
|
22185
|
-
summary: "\u7EDF\u4E00\u5347\u7EA7\u5168\u5C40 CLI \u4E0E\u5F53\u524D\u5DE5\u4F5C\u533A\u5DF2\
|
|
22215
|
+
summary: "\u7EDF\u4E00\u5347\u7EA7\u5168\u5C40 CLI \u4E0E\u672C\u673A/\u5F53\u524D\u5DE5\u4F5C\u533A\u5DF2\u5B89\u88C5\u7684\u5404\u5BBF\u4E3B\u63D2\u4EF6",
|
|
22186
22216
|
usage: upgradeUsage,
|
|
22187
22217
|
updatePolicy: "none",
|
|
22188
22218
|
supportsWorkspaceFlag: true,
|
|
@@ -22217,7 +22247,7 @@ var upgradeCommand = {
|
|
|
22217
22247
|
PBOT_UPGRADING_CLI: targetVersion,
|
|
22218
22248
|
PBOT_UPGRADING_PREVIOUS_VERSION: packageVersion
|
|
22219
22249
|
};
|
|
22220
|
-
return execCliEntry(
|
|
22250
|
+
return execCliEntry(join28(cliResult.globalDirectory, "bin", "pbot.mjs"), ctx.rawArgs, nextEnv);
|
|
22221
22251
|
}
|
|
22222
22252
|
cli = {
|
|
22223
22253
|
state: cliResult.state,
|
|
@@ -22226,19 +22256,17 @@ var upgradeCommand = {
|
|
|
22226
22256
|
detail: cliResult.detail
|
|
22227
22257
|
};
|
|
22228
22258
|
}
|
|
22229
|
-
const targets =
|
|
22259
|
+
const targets = resolveUpgradeTargets(parsed.hosts);
|
|
22230
22260
|
const summary = await executeWorkspaceUpgrade({
|
|
22231
22261
|
workspaceRoot: workspace,
|
|
22232
22262
|
targetVersion,
|
|
22233
22263
|
cli,
|
|
22234
22264
|
targets,
|
|
22235
22265
|
resolveUpgrader: getHostUpgrader,
|
|
22236
|
-
createContext: (
|
|
22266
|
+
createContext: () => ({
|
|
22237
22267
|
workspace,
|
|
22238
22268
|
targetVersion,
|
|
22239
|
-
...target.currentVersion ? { currentVersion: target.currentVersion } : {},
|
|
22240
22269
|
packageRoot,
|
|
22241
|
-
...target.bindingPath ? { bindingPath: target.bindingPath } : {},
|
|
22242
22270
|
env: process.env,
|
|
22243
22271
|
signal: controller.signal,
|
|
22244
22272
|
options: { dshProfile: parsed.dshProfile },
|
|
@@ -22262,18 +22290,14 @@ init_validation();
|
|
|
22262
22290
|
import { mkdir as mkdir5, stat as stat6 } from "node:fs/promises";
|
|
22263
22291
|
init_workspace_config2();
|
|
22264
22292
|
var initUsage = "\u7528\u6CD5\uFF1Apbot init [--workspace <\u76EE\u5F55>] [--json]\n\u521D\u59CB\u5316\u5171\u4EAB\u5DE5\u4F5C\u533A\u8D44\u6599\u5E76\u542F\u7528 Personal Bot\u3002";
|
|
22265
|
-
var statusUsage = "\u7528\u6CD5\uFF1Apbot status [--workspace <\u76EE\u5F55>] [--json]\n\u67E5\u770B\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u3001CLI \u7248\u672C\
|
|
22293
|
+
var statusUsage = "\u7528\u6CD5\uFF1Apbot status [--workspace <\u76EE\u5F55>] [--json]\n\u67E5\u770B\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u3001CLI \u7248\u672C\u4E0E\u914D\u7F6E\u3002";
|
|
22266
22294
|
async function reportWorkspaceStatus(root, compact, checkRelease) {
|
|
22267
22295
|
const configuration = await readWorkspaceConfig(root);
|
|
22268
22296
|
const active = checkRelease || configuration.enabled;
|
|
22269
|
-
const
|
|
22270
|
-
const required = active ? await minimumCliRelease(root, plugins) : void 0;
|
|
22271
|
-
const drift = workspacePluginDrift(plugins);
|
|
22297
|
+
const required = active ? await minimumCliRelease(root) : void 0;
|
|
22272
22298
|
printJson({
|
|
22273
22299
|
workspaceRoot: root,
|
|
22274
22300
|
version: packageVersion,
|
|
22275
|
-
plugins,
|
|
22276
|
-
outOfSync: drift.outOfSync,
|
|
22277
22301
|
minimumCliVersion: required ?? null,
|
|
22278
22302
|
configuration
|
|
22279
22303
|
}, compact);
|
|
@@ -22304,7 +22328,7 @@ var initCommand = {
|
|
|
22304
22328
|
};
|
|
22305
22329
|
var statusCommand = {
|
|
22306
22330
|
name: "status",
|
|
22307
|
-
summary: "\u67E5\u770B\u5DE5\u4F5C\u533A\u72B6\u6001\
|
|
22331
|
+
summary: "\u67E5\u770B\u5DE5\u4F5C\u533A\u72B6\u6001\u3001CLI \u7248\u672C\u4E0E\u914D\u7F6E",
|
|
22308
22332
|
usage: statusUsage,
|
|
22309
22333
|
updatePolicy: "workspace",
|
|
22310
22334
|
supportsWorkspaceFlag: true,
|
|
@@ -22365,7 +22389,7 @@ function formatRootHelp() {
|
|
|
22365
22389
|
return lines.join("\n");
|
|
22366
22390
|
}
|
|
22367
22391
|
async function updateForWorkspace(root, args, input) {
|
|
22368
|
-
return runUpdatedCli(await minimumCliRelease(root
|
|
22392
|
+
return runUpdatedCli(await minimumCliRelease(root), args, input);
|
|
22369
22393
|
}
|
|
22370
22394
|
async function updateForCommand(args) {
|
|
22371
22395
|
if (!args.length) return void 0;
|
|
@@ -22396,10 +22420,10 @@ async function main(args) {
|
|
|
22396
22420
|
try {
|
|
22397
22421
|
if (args[0] === "--at-least") {
|
|
22398
22422
|
const version = args[1];
|
|
22399
|
-
if (args.length !== 2 || !version || !(0,
|
|
22423
|
+
if (args.length !== 2 || !version || !(0, import_semver13.valid)(version)) {
|
|
22400
22424
|
throw new CliError("\u7528\u6CD5\uFF1Apbot --at-least <MAJOR.MINOR.PATCH>", 1);
|
|
22401
22425
|
}
|
|
22402
|
-
return (0,
|
|
22426
|
+
return (0, import_semver13.gte)(packageVersion, version) ? 0 : 1;
|
|
22403
22427
|
}
|
|
22404
22428
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
|
|
22405
22429
|
console.log(packageVersion);
|