personal-bot 0.3.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +348 -203
- package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
- package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +348 -203
- package/lib/extension/cli.js +574 -549
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +48 -62
- package/lib/extension/mcp/workers.d.ts +13 -27
- package/lib/extension/mcp/workers.js +60 -25
- package/lib/extension/mcp.js +462 -326
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.js +2 -2
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +180 -126
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/tools/history/contract.js +12 -12
- package/package.json +1 -1
- package/resources/agents/coordinator.md +3 -7
- package/resources/agents/general-purpose.md +3 -3
- package/resources/antigravity/skills/pbot/SKILL.md +14 -6
- package/resources/claude/skills/pbot/SKILL.md +14 -6
- package/resources/plugin/skills/pbot/SKILL.md +2 -2
- package/resources/prompts/history-coordinator.md +1 -2
- package/resources/prompts/plugin-coordinator.md +1 -2
- package/resources/prompts/workspace.md +12 -16
- package/resources/skills/provider-connections/SKILL.md +7 -6
- package/resources/templates/workspace-agents.md +0 -4
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +48 -62
- package/src/extension/mcp/workers.ts +66 -27
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +2 -2
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +2 -2
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +204 -133
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/tools/history/contract.ts +12 -12
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
- package/lib/antigravity-plugin/resources/references/compute.md +0 -16
- package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
- package/src/services/workspace/plugin-releases.ts +0 -121
package/lib/extension/cli.js
CHANGED
|
@@ -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" });
|
|
@@ -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");
|
|
@@ -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) {
|
|
@@ -13446,13 +13446,13 @@ var require_boolSchema = __commonJS({
|
|
|
13446
13446
|
}
|
|
13447
13447
|
}
|
|
13448
13448
|
exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
13449
|
-
function boolOrEmptySchema(it,
|
|
13449
|
+
function boolOrEmptySchema(it, valid15) {
|
|
13450
13450
|
const { gen, schema: schema2 } = it;
|
|
13451
13451
|
if (schema2 === false) {
|
|
13452
|
-
gen.var(
|
|
13452
|
+
gen.var(valid15, false);
|
|
13453
13453
|
falseSchemaError(it);
|
|
13454
13454
|
} else {
|
|
13455
|
-
gen.var(
|
|
13455
|
+
gen.var(valid15, true);
|
|
13456
13456
|
}
|
|
13457
13457
|
}
|
|
13458
13458
|
exports.boolOrEmptySchema = boolOrEmptySchema;
|
|
@@ -13833,15 +13833,15 @@ var require_code2 = __commonJS({
|
|
|
13833
13833
|
exports.usePattern = usePattern;
|
|
13834
13834
|
function validateArray(cxt) {
|
|
13835
13835
|
const { gen, data, keyword, it } = cxt;
|
|
13836
|
-
const
|
|
13836
|
+
const valid15 = gen.name("valid");
|
|
13837
13837
|
if (it.allErrors) {
|
|
13838
13838
|
const validArr = gen.let("valid", true);
|
|
13839
13839
|
validateItems(() => gen.assign(validArr, false));
|
|
13840
13840
|
return validArr;
|
|
13841
13841
|
}
|
|
13842
|
-
gen.var(
|
|
13842
|
+
gen.var(valid15, true);
|
|
13843
13843
|
validateItems(() => gen.break());
|
|
13844
|
-
return
|
|
13844
|
+
return valid15;
|
|
13845
13845
|
function validateItems(notValid) {
|
|
13846
13846
|
const len = gen.const("len", (0, codegen_1._)`${data}.length`);
|
|
13847
13847
|
gen.forRange("i", 0, len, (i) => {
|
|
@@ -13849,8 +13849,8 @@ var require_code2 = __commonJS({
|
|
|
13849
13849
|
keyword,
|
|
13850
13850
|
dataProp: i,
|
|
13851
13851
|
dataPropType: util_1.Type.Num
|
|
13852
|
-
},
|
|
13853
|
-
gen.if((0, codegen_1.not)(
|
|
13852
|
+
}, valid15);
|
|
13853
|
+
gen.if((0, codegen_1.not)(valid15), notValid);
|
|
13854
13854
|
});
|
|
13855
13855
|
}
|
|
13856
13856
|
}
|
|
@@ -13862,7 +13862,7 @@ var require_code2 = __commonJS({
|
|
|
13862
13862
|
const alwaysValid = schema2.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
|
|
13863
13863
|
if (alwaysValid && !it.opts.unevaluated)
|
|
13864
13864
|
return;
|
|
13865
|
-
const
|
|
13865
|
+
const valid15 = gen.let("valid", false);
|
|
13866
13866
|
const schValid = gen.name("_valid");
|
|
13867
13867
|
gen.block(() => schema2.forEach((_sch, i) => {
|
|
13868
13868
|
const schCxt = cxt.subschema({
|
|
@@ -13870,12 +13870,12 @@ var require_code2 = __commonJS({
|
|
|
13870
13870
|
schemaProp: i,
|
|
13871
13871
|
compositeRule: true
|
|
13872
13872
|
}, schValid);
|
|
13873
|
-
gen.assign(
|
|
13873
|
+
gen.assign(valid15, (0, codegen_1._)`${valid15} || ${schValid}`);
|
|
13874
13874
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
13875
13875
|
if (!merged)
|
|
13876
|
-
gen.if((0, codegen_1.not)(
|
|
13876
|
+
gen.if((0, codegen_1.not)(valid15));
|
|
13877
13877
|
}));
|
|
13878
|
-
cxt.result(
|
|
13878
|
+
cxt.result(valid15, () => cxt.reset(), () => cxt.error(true));
|
|
13879
13879
|
}
|
|
13880
13880
|
exports.validateUnion = validateUnion;
|
|
13881
13881
|
}
|
|
@@ -13897,15 +13897,15 @@ var require_keyword = __commonJS({
|
|
|
13897
13897
|
const schemaRef = useKeyword(gen, keyword, macroSchema);
|
|
13898
13898
|
if (it.opts.validateSchema !== false)
|
|
13899
13899
|
it.self.validateSchema(macroSchema, true);
|
|
13900
|
-
const
|
|
13900
|
+
const valid15 = gen.name("valid");
|
|
13901
13901
|
cxt.subschema({
|
|
13902
13902
|
schema: macroSchema,
|
|
13903
13903
|
schemaPath: codegen_1.nil,
|
|
13904
13904
|
errSchemaPath: `${it.errSchemaPath}/${keyword}`,
|
|
13905
13905
|
topSchemaRef: schemaRef,
|
|
13906
13906
|
compositeRule: true
|
|
13907
|
-
},
|
|
13908
|
-
cxt.pass(
|
|
13907
|
+
}, valid15);
|
|
13908
|
+
cxt.pass(valid15, () => cxt.error(true));
|
|
13909
13909
|
}
|
|
13910
13910
|
exports.macroKeywordCode = macroKeywordCode;
|
|
13911
13911
|
function funcKeywordCode(cxt, def) {
|
|
@@ -13914,9 +13914,9 @@ var require_keyword = __commonJS({
|
|
|
13914
13914
|
checkAsyncKeyword(it, def);
|
|
13915
13915
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema2, parentSchema, it) : def.validate;
|
|
13916
13916
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
13917
|
-
const
|
|
13918
|
-
cxt.block$data(
|
|
13919
|
-
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a :
|
|
13917
|
+
const valid15 = gen.let("valid");
|
|
13918
|
+
cxt.block$data(valid15, validateKeyword);
|
|
13919
|
+
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid15);
|
|
13920
13920
|
function validateKeyword() {
|
|
13921
13921
|
if (def.errors === false) {
|
|
13922
13922
|
assignValid();
|
|
@@ -13932,7 +13932,7 @@ var require_keyword = __commonJS({
|
|
|
13932
13932
|
}
|
|
13933
13933
|
function validateAsync() {
|
|
13934
13934
|
const ruleErrs = gen.let("ruleErrs", null);
|
|
13935
|
-
gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(
|
|
13935
|
+
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
13936
|
return ruleErrs;
|
|
13937
13937
|
}
|
|
13938
13938
|
function validateSync() {
|
|
@@ -13944,11 +13944,11 @@ var require_keyword = __commonJS({
|
|
|
13944
13944
|
function assignValid(_await = def.async ? (0, codegen_1._)`await ` : codegen_1.nil) {
|
|
13945
13945
|
const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self;
|
|
13946
13946
|
const passSchema = !("compile" in def && !$data || def.schema === false);
|
|
13947
|
-
gen.assign(
|
|
13947
|
+
gen.assign(valid15, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
13948
13948
|
}
|
|
13949
13949
|
function reportErrs(errors) {
|
|
13950
13950
|
var _a2;
|
|
13951
|
-
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 :
|
|
13951
|
+
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid15), errors);
|
|
13952
13952
|
}
|
|
13953
13953
|
}
|
|
13954
13954
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -13985,8 +13985,8 @@ var require_keyword = __commonJS({
|
|
|
13985
13985
|
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
|
|
13986
13986
|
}
|
|
13987
13987
|
if (def.validateSchema) {
|
|
13988
|
-
const
|
|
13989
|
-
if (!
|
|
13988
|
+
const valid15 = def.validateSchema(schema2[keyword]);
|
|
13989
|
+
if (!valid15) {
|
|
13990
13990
|
const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def.validateSchema.errors);
|
|
13991
13991
|
if (opts.validateSchema === "log")
|
|
13992
13992
|
self.logger.error(msg);
|
|
@@ -14446,15 +14446,15 @@ var require_validate = __commonJS({
|
|
|
14446
14446
|
const schId = typeof schema2 == "object" && schema2[opts.schemaId];
|
|
14447
14447
|
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
|
|
14448
14448
|
}
|
|
14449
|
-
function subschemaCode(it,
|
|
14449
|
+
function subschemaCode(it, valid15) {
|
|
14450
14450
|
if (isSchemaObj(it)) {
|
|
14451
14451
|
checkKeywords(it);
|
|
14452
14452
|
if (schemaCxtHasRules(it)) {
|
|
14453
|
-
subSchemaObjCode(it,
|
|
14453
|
+
subSchemaObjCode(it, valid15);
|
|
14454
14454
|
return;
|
|
14455
14455
|
}
|
|
14456
14456
|
}
|
|
14457
|
-
(0, boolSchema_1.boolOrEmptySchema)(it,
|
|
14457
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid15);
|
|
14458
14458
|
}
|
|
14459
14459
|
function schemaCxtHasRules({ schema: schema2, self }) {
|
|
14460
14460
|
if (typeof schema2 == "boolean")
|
|
@@ -14467,7 +14467,7 @@ var require_validate = __commonJS({
|
|
|
14467
14467
|
function isSchemaObj(it) {
|
|
14468
14468
|
return typeof it.schema != "boolean";
|
|
14469
14469
|
}
|
|
14470
|
-
function subSchemaObjCode(it,
|
|
14470
|
+
function subSchemaObjCode(it, valid15) {
|
|
14471
14471
|
const { schema: schema2, gen, opts } = it;
|
|
14472
14472
|
if (opts.$comment && schema2.$comment)
|
|
14473
14473
|
commentKeyword(it);
|
|
@@ -14475,7 +14475,7 @@ var require_validate = __commonJS({
|
|
|
14475
14475
|
checkAsyncSchema(it);
|
|
14476
14476
|
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
14477
14477
|
typeAndKeywords(it, errsCount);
|
|
14478
|
-
gen.var(
|
|
14478
|
+
gen.var(valid15, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
14479
14479
|
}
|
|
14480
14480
|
function checkKeywords(it) {
|
|
14481
14481
|
(0, util_1.checkUnknownRules)(it);
|
|
@@ -14742,24 +14742,24 @@ var require_validate = __commonJS({
|
|
|
14742
14742
|
else
|
|
14743
14743
|
this.params = obj;
|
|
14744
14744
|
}
|
|
14745
|
-
block$data(
|
|
14745
|
+
block$data(valid15, codeBlock, $dataValid = codegen_1.nil) {
|
|
14746
14746
|
this.gen.block(() => {
|
|
14747
|
-
this.check$data(
|
|
14747
|
+
this.check$data(valid15, $dataValid);
|
|
14748
14748
|
codeBlock();
|
|
14749
14749
|
});
|
|
14750
14750
|
}
|
|
14751
|
-
check$data(
|
|
14751
|
+
check$data(valid15 = codegen_1.nil, $dataValid = codegen_1.nil) {
|
|
14752
14752
|
if (!this.$data)
|
|
14753
14753
|
return;
|
|
14754
14754
|
const { gen, schemaCode, schemaType, def } = this;
|
|
14755
14755
|
gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid));
|
|
14756
|
-
if (
|
|
14757
|
-
gen.assign(
|
|
14756
|
+
if (valid15 !== codegen_1.nil)
|
|
14757
|
+
gen.assign(valid15, true);
|
|
14758
14758
|
if (schemaType.length || def.validateSchema) {
|
|
14759
14759
|
gen.elseIf(this.invalid$data());
|
|
14760
14760
|
this.$dataError();
|
|
14761
|
-
if (
|
|
14762
|
-
gen.assign(
|
|
14761
|
+
if (valid15 !== codegen_1.nil)
|
|
14762
|
+
gen.assign(valid15, false);
|
|
14763
14763
|
}
|
|
14764
14764
|
gen.else();
|
|
14765
14765
|
}
|
|
@@ -14783,12 +14783,12 @@ var require_validate = __commonJS({
|
|
|
14783
14783
|
return codegen_1.nil;
|
|
14784
14784
|
}
|
|
14785
14785
|
}
|
|
14786
|
-
subschema(appl,
|
|
14786
|
+
subschema(appl, valid15) {
|
|
14787
14787
|
const subschema = (0, subschema_1.getSubschema)(this.it, appl);
|
|
14788
14788
|
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
|
|
14789
14789
|
(0, subschema_1.extendSubschemaMode)(subschema, appl);
|
|
14790
14790
|
const nextContext = { ...this.it, ...subschema, items: void 0, props: void 0 };
|
|
14791
|
-
subschemaCode(nextContext,
|
|
14791
|
+
subschemaCode(nextContext, valid15);
|
|
14792
14792
|
return nextContext;
|
|
14793
14793
|
}
|
|
14794
14794
|
mergeEvaluated(schemaCxt, toName) {
|
|
@@ -14802,10 +14802,10 @@ var require_validate = __commonJS({
|
|
|
14802
14802
|
it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
14803
14803
|
}
|
|
14804
14804
|
}
|
|
14805
|
-
mergeValidEvaluated(schemaCxt,
|
|
14805
|
+
mergeValidEvaluated(schemaCxt, valid15) {
|
|
14806
14806
|
const { it, gen } = this;
|
|
14807
14807
|
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
14808
|
-
gen.if(
|
|
14808
|
+
gen.if(valid15, () => this.mergeEvaluated(schemaCxt, codegen_1.Name));
|
|
14809
14809
|
return true;
|
|
14810
14810
|
}
|
|
14811
14811
|
}
|
|
@@ -15026,7 +15026,7 @@ var require_compile = __commonJS({
|
|
|
15026
15026
|
const schOrFunc = root.refs[ref];
|
|
15027
15027
|
if (schOrFunc)
|
|
15028
15028
|
return schOrFunc;
|
|
15029
|
-
let _sch =
|
|
15029
|
+
let _sch = resolve10.call(this, root, ref);
|
|
15030
15030
|
if (_sch === void 0) {
|
|
15031
15031
|
const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
15032
15032
|
const { schemaId } = this.opts;
|
|
@@ -15053,7 +15053,7 @@ var require_compile = __commonJS({
|
|
|
15053
15053
|
function sameSchemaEnv(s1, s2) {
|
|
15054
15054
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
15055
15055
|
}
|
|
15056
|
-
function
|
|
15056
|
+
function resolve10(root, ref) {
|
|
15057
15057
|
let sch;
|
|
15058
15058
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
15059
15059
|
ref = sch;
|
|
@@ -15917,7 +15917,7 @@ var require_fast_uri = __commonJS({
|
|
|
15917
15917
|
}
|
|
15918
15918
|
return uri;
|
|
15919
15919
|
}
|
|
15920
|
-
function
|
|
15920
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
15921
15921
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
15922
15922
|
const {
|
|
15923
15923
|
parsed: baseParsed,
|
|
@@ -16308,7 +16308,7 @@ var require_fast_uri = __commonJS({
|
|
|
16308
16308
|
var fastUri = {
|
|
16309
16309
|
SCHEMES,
|
|
16310
16310
|
normalize,
|
|
16311
|
-
resolve:
|
|
16311
|
+
resolve: resolve10,
|
|
16312
16312
|
resolveComponent,
|
|
16313
16313
|
equal,
|
|
16314
16314
|
serialize,
|
|
@@ -16495,10 +16495,10 @@ var require_core = __commonJS({
|
|
|
16495
16495
|
} else {
|
|
16496
16496
|
v = this.compile(schemaKeyRef);
|
|
16497
16497
|
}
|
|
16498
|
-
const
|
|
16498
|
+
const valid15 = v(data);
|
|
16499
16499
|
if (!("$async" in v))
|
|
16500
16500
|
this.errors = v.errors;
|
|
16501
|
-
return
|
|
16501
|
+
return valid15;
|
|
16502
16502
|
}
|
|
16503
16503
|
compile(schema2, _meta) {
|
|
16504
16504
|
const sch = this._addSchema(schema2, _meta);
|
|
@@ -16595,15 +16595,15 @@ var require_core = __commonJS({
|
|
|
16595
16595
|
this.errors = null;
|
|
16596
16596
|
return true;
|
|
16597
16597
|
}
|
|
16598
|
-
const
|
|
16599
|
-
if (!
|
|
16598
|
+
const valid15 = this.validate($schema, schema2);
|
|
16599
|
+
if (!valid15 && throwOrLogError) {
|
|
16600
16600
|
const message = "schema is invalid: " + this.errorsText();
|
|
16601
16601
|
if (this.opts.validateSchema === "log")
|
|
16602
16602
|
this.logger.error(message);
|
|
16603
16603
|
else
|
|
16604
16604
|
throw new Error(message);
|
|
16605
16605
|
}
|
|
16606
|
-
return
|
|
16606
|
+
return valid15;
|
|
16607
16607
|
}
|
|
16608
16608
|
// Get compiled schema by `key` or `ref`.
|
|
16609
16609
|
// (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id)
|
|
@@ -16996,16 +16996,16 @@ var require_ref = __commonJS({
|
|
|
16996
16996
|
}
|
|
16997
16997
|
function inlineRefSchema(sch) {
|
|
16998
16998
|
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch });
|
|
16999
|
-
const
|
|
16999
|
+
const valid15 = gen.name("valid");
|
|
17000
17000
|
const schCxt = cxt.subschema({
|
|
17001
17001
|
schema: sch,
|
|
17002
17002
|
dataTypes: [],
|
|
17003
17003
|
schemaPath: codegen_1.nil,
|
|
17004
17004
|
topSchemaRef: schName,
|
|
17005
17005
|
errSchemaPath: $ref
|
|
17006
|
-
},
|
|
17006
|
+
}, valid15);
|
|
17007
17007
|
cxt.mergeEvaluated(schCxt);
|
|
17008
|
-
cxt.ok(
|
|
17008
|
+
cxt.ok(valid15);
|
|
17009
17009
|
}
|
|
17010
17010
|
}
|
|
17011
17011
|
};
|
|
@@ -17025,19 +17025,19 @@ var require_ref = __commonJS({
|
|
|
17025
17025
|
function callAsyncRef() {
|
|
17026
17026
|
if (!env.$async)
|
|
17027
17027
|
throw new Error("async schema referenced by sync schema");
|
|
17028
|
-
const
|
|
17028
|
+
const valid15 = gen.let("valid");
|
|
17029
17029
|
gen.try(() => {
|
|
17030
17030
|
gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`);
|
|
17031
17031
|
addEvaluatedFrom(v);
|
|
17032
17032
|
if (!allErrors)
|
|
17033
|
-
gen.assign(
|
|
17033
|
+
gen.assign(valid15, true);
|
|
17034
17034
|
}, (e) => {
|
|
17035
17035
|
gen.if((0, codegen_1._)`!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
|
|
17036
17036
|
addErrorsFrom(e);
|
|
17037
17037
|
if (!allErrors)
|
|
17038
|
-
gen.assign(
|
|
17038
|
+
gen.assign(valid15, false);
|
|
17039
17039
|
});
|
|
17040
|
-
cxt.ok(
|
|
17040
|
+
cxt.ok(valid15);
|
|
17041
17041
|
}
|
|
17042
17042
|
function callSyncRef() {
|
|
17043
17043
|
cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
|
|
@@ -17242,9 +17242,9 @@ var require_pattern = __commonJS({
|
|
|
17242
17242
|
if ($data) {
|
|
17243
17243
|
const { regExp } = it.opts.code;
|
|
17244
17244
|
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._)`!${
|
|
17245
|
+
const valid15 = gen.let("valid");
|
|
17246
|
+
gen.try(() => gen.assign(valid15, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid15, false));
|
|
17247
|
+
cxt.fail$data((0, codegen_1._)`!${valid15}`);
|
|
17248
17248
|
} else {
|
|
17249
17249
|
const regExp = (0, code_1.usePattern)(cxt, schema2);
|
|
17250
17250
|
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
@@ -17335,9 +17335,9 @@ var require_required = __commonJS({
|
|
|
17335
17335
|
function exitOnErrorMode() {
|
|
17336
17336
|
const missing = gen.let("missing");
|
|
17337
17337
|
if (useLoop || $data) {
|
|
17338
|
-
const
|
|
17339
|
-
cxt.block$data(
|
|
17340
|
-
cxt.ok(
|
|
17338
|
+
const valid15 = gen.let("valid", true);
|
|
17339
|
+
cxt.block$data(valid15, () => loopUntilMissing(missing, valid15));
|
|
17340
|
+
cxt.ok(valid15);
|
|
17341
17341
|
} else {
|
|
17342
17342
|
gen.if((0, code_1.checkMissingProp)(cxt, schema2, missing));
|
|
17343
17343
|
(0, code_1.reportMissingProp)(cxt, missing);
|
|
@@ -17350,11 +17350,11 @@ var require_required = __commonJS({
|
|
|
17350
17350
|
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
|
|
17351
17351
|
});
|
|
17352
17352
|
}
|
|
17353
|
-
function loopUntilMissing(missing,
|
|
17353
|
+
function loopUntilMissing(missing, valid15) {
|
|
17354
17354
|
cxt.setParams({ missingProperty: missing });
|
|
17355
17355
|
gen.forOf(missing, schemaCode, () => {
|
|
17356
|
-
gen.assign(
|
|
17357
|
-
gen.if((0, codegen_1.not)(
|
|
17356
|
+
gen.assign(valid15, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
|
|
17357
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
17358
17358
|
cxt.error();
|
|
17359
17359
|
gen.break();
|
|
17360
17360
|
});
|
|
@@ -17429,15 +17429,15 @@ var require_uniqueItems = __commonJS({
|
|
|
17429
17429
|
const { gen, data, $data, schema: schema2, parentSchema, schemaCode, it } = cxt;
|
|
17430
17430
|
if (!$data && !schema2)
|
|
17431
17431
|
return;
|
|
17432
|
-
const
|
|
17432
|
+
const valid15 = gen.let("valid");
|
|
17433
17433
|
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
|
|
17434
|
-
cxt.block$data(
|
|
17435
|
-
cxt.ok(
|
|
17434
|
+
cxt.block$data(valid15, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`);
|
|
17435
|
+
cxt.ok(valid15);
|
|
17436
17436
|
function validateUniqueItems() {
|
|
17437
17437
|
const i = gen.let("i", (0, codegen_1._)`${data}.length`);
|
|
17438
17438
|
const j = gen.let("j");
|
|
17439
17439
|
cxt.setParams({ i, j });
|
|
17440
|
-
gen.assign(
|
|
17440
|
+
gen.assign(valid15, true);
|
|
17441
17441
|
gen.if((0, codegen_1._)`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
|
|
17442
17442
|
}
|
|
17443
17443
|
function canOptimize() {
|
|
@@ -17455,7 +17455,7 @@ var require_uniqueItems = __commonJS({
|
|
|
17455
17455
|
gen.if((0, codegen_1._)`typeof ${indices}[${item}] == "number"`, () => {
|
|
17456
17456
|
gen.assign(j, (0, codegen_1._)`${indices}[${item}]`);
|
|
17457
17457
|
cxt.error();
|
|
17458
|
-
gen.assign(
|
|
17458
|
+
gen.assign(valid15, false).break();
|
|
17459
17459
|
}).code((0, codegen_1._)`${indices}[${item}] = ${i}`);
|
|
17460
17460
|
});
|
|
17461
17461
|
}
|
|
@@ -17464,7 +17464,7 @@ var require_uniqueItems = __commonJS({
|
|
|
17464
17464
|
const outer = gen.name("outer");
|
|
17465
17465
|
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
17466
|
cxt.error();
|
|
17467
|
-
gen.assign(
|
|
17467
|
+
gen.assign(valid15, false).break(outer);
|
|
17468
17468
|
})));
|
|
17469
17469
|
}
|
|
17470
17470
|
}
|
|
@@ -17526,20 +17526,20 @@ var require_enum = __commonJS({
|
|
|
17526
17526
|
const useLoop = schema2.length >= it.opts.loopEnum;
|
|
17527
17527
|
let eql;
|
|
17528
17528
|
const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default);
|
|
17529
|
-
let
|
|
17529
|
+
let valid15;
|
|
17530
17530
|
if (useLoop || $data) {
|
|
17531
|
-
|
|
17532
|
-
cxt.block$data(
|
|
17531
|
+
valid15 = gen.let("valid");
|
|
17532
|
+
cxt.block$data(valid15, loopEnum);
|
|
17533
17533
|
} else {
|
|
17534
17534
|
if (!Array.isArray(schema2))
|
|
17535
17535
|
throw new Error("ajv implementation error");
|
|
17536
17536
|
const vSchema = gen.const("vSchema", schemaCode);
|
|
17537
|
-
|
|
17537
|
+
valid15 = (0, codegen_1.or)(...schema2.map((_x, i) => equalCode(vSchema, i)));
|
|
17538
17538
|
}
|
|
17539
|
-
cxt.pass(
|
|
17539
|
+
cxt.pass(valid15);
|
|
17540
17540
|
function loopEnum() {
|
|
17541
|
-
gen.assign(
|
|
17542
|
-
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(
|
|
17541
|
+
gen.assign(valid15, false);
|
|
17542
|
+
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(valid15, true).break()));
|
|
17543
17543
|
}
|
|
17544
17544
|
function equalCode(vSchema, i) {
|
|
17545
17545
|
const sch = schema2[i];
|
|
@@ -17625,15 +17625,15 @@ var require_additionalItems = __commonJS({
|
|
|
17625
17625
|
cxt.setParams({ len: items.length });
|
|
17626
17626
|
cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
|
|
17627
17627
|
} else if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
|
|
17628
|
-
const
|
|
17629
|
-
gen.if((0, codegen_1.not)(
|
|
17630
|
-
cxt.ok(
|
|
17628
|
+
const valid15 = gen.var("valid", (0, codegen_1._)`${len} <= ${items.length}`);
|
|
17629
|
+
gen.if((0, codegen_1.not)(valid15), () => validateItems(valid15));
|
|
17630
|
+
cxt.ok(valid15);
|
|
17631
17631
|
}
|
|
17632
|
-
function validateItems(
|
|
17632
|
+
function validateItems(valid15) {
|
|
17633
17633
|
gen.forRange("i", items.length, len, (i) => {
|
|
17634
|
-
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num },
|
|
17634
|
+
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid15);
|
|
17635
17635
|
if (!it.allErrors)
|
|
17636
|
-
gen.if((0, codegen_1.not)(
|
|
17636
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
17637
17637
|
});
|
|
17638
17638
|
}
|
|
17639
17639
|
}
|
|
@@ -17672,7 +17672,7 @@ var require_items = __commonJS({
|
|
|
17672
17672
|
if (it.opts.unevaluated && schArr.length && it.items !== true) {
|
|
17673
17673
|
it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
|
|
17674
17674
|
}
|
|
17675
|
-
const
|
|
17675
|
+
const valid15 = gen.name("valid");
|
|
17676
17676
|
const len = gen.const("len", (0, codegen_1._)`${data}.length`);
|
|
17677
17677
|
schArr.forEach((sch, i) => {
|
|
17678
17678
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
@@ -17681,8 +17681,8 @@ var require_items = __commonJS({
|
|
|
17681
17681
|
keyword,
|
|
17682
17682
|
schemaProp: i,
|
|
17683
17683
|
dataProp: i
|
|
17684
|
-
},
|
|
17685
|
-
cxt.ok(
|
|
17684
|
+
}, valid15));
|
|
17685
|
+
cxt.ok(valid15);
|
|
17686
17686
|
});
|
|
17687
17687
|
function checkStrictTuple(sch) {
|
|
17688
17688
|
const { opts, errSchemaPath } = it;
|
|
@@ -17799,18 +17799,18 @@ var require_contains = __commonJS({
|
|
|
17799
17799
|
return;
|
|
17800
17800
|
}
|
|
17801
17801
|
it.items = true;
|
|
17802
|
-
const
|
|
17802
|
+
const valid15 = gen.name("valid");
|
|
17803
17803
|
if (max === void 0 && min === 1) {
|
|
17804
|
-
validateItems(
|
|
17804
|
+
validateItems(valid15, () => gen.if(valid15, () => gen.break()));
|
|
17805
17805
|
} else if (min === 0) {
|
|
17806
|
-
gen.let(
|
|
17806
|
+
gen.let(valid15, true);
|
|
17807
17807
|
if (max !== void 0)
|
|
17808
17808
|
gen.if((0, codegen_1._)`${data}.length > 0`, validateItemsWithCount);
|
|
17809
17809
|
} else {
|
|
17810
|
-
gen.let(
|
|
17810
|
+
gen.let(valid15, false);
|
|
17811
17811
|
validateItemsWithCount();
|
|
17812
17812
|
}
|
|
17813
|
-
cxt.result(
|
|
17813
|
+
cxt.result(valid15, () => cxt.reset());
|
|
17814
17814
|
function validateItemsWithCount() {
|
|
17815
17815
|
const schValid = gen.name("_valid");
|
|
17816
17816
|
const count = gen.let("count", 0);
|
|
@@ -17830,13 +17830,13 @@ var require_contains = __commonJS({
|
|
|
17830
17830
|
function checkLimits(count) {
|
|
17831
17831
|
gen.code((0, codegen_1._)`${count}++`);
|
|
17832
17832
|
if (max === void 0) {
|
|
17833
|
-
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(
|
|
17833
|
+
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid15, true).break());
|
|
17834
17834
|
} else {
|
|
17835
|
-
gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(
|
|
17835
|
+
gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid15, false).break());
|
|
17836
17836
|
if (min === 1)
|
|
17837
|
-
gen.assign(
|
|
17837
|
+
gen.assign(valid15, true);
|
|
17838
17838
|
else
|
|
17839
|
-
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(
|
|
17839
|
+
gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid15, true));
|
|
17840
17840
|
}
|
|
17841
17841
|
}
|
|
17842
17842
|
}
|
|
@@ -17918,20 +17918,20 @@ var require_dependencies = __commonJS({
|
|
|
17918
17918
|
exports.validatePropertyDeps = validatePropertyDeps;
|
|
17919
17919
|
function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
|
|
17920
17920
|
const { gen, data, keyword, it } = cxt;
|
|
17921
|
-
const
|
|
17921
|
+
const valid15 = gen.name("valid");
|
|
17922
17922
|
for (const prop in schemaDeps) {
|
|
17923
17923
|
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
|
|
17924
17924
|
continue;
|
|
17925
17925
|
gen.if(
|
|
17926
17926
|
(0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties),
|
|
17927
17927
|
() => {
|
|
17928
|
-
const schCxt = cxt.subschema({ keyword, schemaProp: prop },
|
|
17929
|
-
cxt.mergeValidEvaluated(schCxt,
|
|
17928
|
+
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid15);
|
|
17929
|
+
cxt.mergeValidEvaluated(schCxt, valid15);
|
|
17930
17930
|
},
|
|
17931
|
-
() => gen.var(
|
|
17931
|
+
() => gen.var(valid15, true)
|
|
17932
17932
|
// TODO var
|
|
17933
17933
|
);
|
|
17934
|
-
cxt.ok(
|
|
17934
|
+
cxt.ok(valid15);
|
|
17935
17935
|
}
|
|
17936
17936
|
}
|
|
17937
17937
|
exports.validateSchemaDeps = validateSchemaDeps;
|
|
@@ -17959,7 +17959,7 @@ var require_propertyNames = __commonJS({
|
|
|
17959
17959
|
const { gen, schema: schema2, data, it } = cxt;
|
|
17960
17960
|
if ((0, util_1.alwaysValidSchema)(it, schema2))
|
|
17961
17961
|
return;
|
|
17962
|
-
const
|
|
17962
|
+
const valid15 = gen.name("valid");
|
|
17963
17963
|
gen.forIn("key", data, (key) => {
|
|
17964
17964
|
cxt.setParams({ propertyName: key });
|
|
17965
17965
|
cxt.subschema({
|
|
@@ -17968,14 +17968,14 @@ var require_propertyNames = __commonJS({
|
|
|
17968
17968
|
dataTypes: ["string"],
|
|
17969
17969
|
propertyName: key,
|
|
17970
17970
|
compositeRule: true
|
|
17971
|
-
},
|
|
17972
|
-
gen.if((0, codegen_1.not)(
|
|
17971
|
+
}, valid15);
|
|
17972
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
17973
17973
|
cxt.error(true);
|
|
17974
17974
|
if (!it.allErrors)
|
|
17975
17975
|
gen.break();
|
|
17976
17976
|
});
|
|
17977
17977
|
});
|
|
17978
|
-
cxt.ok(
|
|
17978
|
+
cxt.ok(valid15);
|
|
17979
17979
|
}
|
|
17980
17980
|
};
|
|
17981
17981
|
exports.default = def;
|
|
@@ -18053,21 +18053,21 @@ var require_additionalProperties = __commonJS({
|
|
|
18053
18053
|
return;
|
|
18054
18054
|
}
|
|
18055
18055
|
if (typeof schema2 == "object" && !(0, util_1.alwaysValidSchema)(it, schema2)) {
|
|
18056
|
-
const
|
|
18056
|
+
const valid15 = gen.name("valid");
|
|
18057
18057
|
if (opts.removeAdditional === "failing") {
|
|
18058
|
-
applyAdditionalSchema(key,
|
|
18059
|
-
gen.if((0, codegen_1.not)(
|
|
18058
|
+
applyAdditionalSchema(key, valid15, false);
|
|
18059
|
+
gen.if((0, codegen_1.not)(valid15), () => {
|
|
18060
18060
|
cxt.reset();
|
|
18061
18061
|
deleteAdditional(key);
|
|
18062
18062
|
});
|
|
18063
18063
|
} else {
|
|
18064
|
-
applyAdditionalSchema(key,
|
|
18064
|
+
applyAdditionalSchema(key, valid15);
|
|
18065
18065
|
if (!allErrors)
|
|
18066
|
-
gen.if((0, codegen_1.not)(
|
|
18066
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
18067
18067
|
}
|
|
18068
18068
|
}
|
|
18069
18069
|
}
|
|
18070
|
-
function applyAdditionalSchema(key,
|
|
18070
|
+
function applyAdditionalSchema(key, valid15, errors) {
|
|
18071
18071
|
const subschema = {
|
|
18072
18072
|
keyword: "additionalProperties",
|
|
18073
18073
|
dataProp: key,
|
|
@@ -18080,7 +18080,7 @@ var require_additionalProperties = __commonJS({
|
|
|
18080
18080
|
allErrors: false
|
|
18081
18081
|
});
|
|
18082
18082
|
}
|
|
18083
|
-
cxt.subschema(subschema,
|
|
18083
|
+
cxt.subschema(subschema, valid15);
|
|
18084
18084
|
}
|
|
18085
18085
|
}
|
|
18086
18086
|
};
|
|
@@ -18116,7 +18116,7 @@ var require_properties = __commonJS({
|
|
|
18116
18116
|
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema2[p]));
|
|
18117
18117
|
if (properties.length === 0)
|
|
18118
18118
|
return;
|
|
18119
|
-
const
|
|
18119
|
+
const valid15 = gen.name("valid");
|
|
18120
18120
|
for (const prop of properties) {
|
|
18121
18121
|
if (hasDefault(prop)) {
|
|
18122
18122
|
applyPropertySchema(prop);
|
|
@@ -18124,11 +18124,11 @@ var require_properties = __commonJS({
|
|
|
18124
18124
|
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
|
|
18125
18125
|
applyPropertySchema(prop);
|
|
18126
18126
|
if (!it.allErrors)
|
|
18127
|
-
gen.else().var(
|
|
18127
|
+
gen.else().var(valid15, true);
|
|
18128
18128
|
gen.endIf();
|
|
18129
18129
|
}
|
|
18130
18130
|
cxt.it.definedProperties.add(prop);
|
|
18131
|
-
cxt.ok(
|
|
18131
|
+
cxt.ok(valid15);
|
|
18132
18132
|
}
|
|
18133
18133
|
function hasDefault(prop) {
|
|
18134
18134
|
return it.opts.useDefaults && !it.compositeRule && schema2[prop].default !== void 0;
|
|
@@ -18138,7 +18138,7 @@ var require_properties = __commonJS({
|
|
|
18138
18138
|
keyword: "properties",
|
|
18139
18139
|
schemaProp: prop,
|
|
18140
18140
|
dataProp: prop
|
|
18141
|
-
},
|
|
18141
|
+
}, valid15);
|
|
18142
18142
|
}
|
|
18143
18143
|
}
|
|
18144
18144
|
};
|
|
@@ -18168,7 +18168,7 @@ var require_patternProperties = __commonJS({
|
|
|
18168
18168
|
return;
|
|
18169
18169
|
}
|
|
18170
18170
|
const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
|
|
18171
|
-
const
|
|
18171
|
+
const valid15 = gen.name("valid");
|
|
18172
18172
|
if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
|
|
18173
18173
|
it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
|
|
18174
18174
|
}
|
|
@@ -18181,9 +18181,9 @@ var require_patternProperties = __commonJS({
|
|
|
18181
18181
|
if (it.allErrors) {
|
|
18182
18182
|
validateProperties(pat);
|
|
18183
18183
|
} else {
|
|
18184
|
-
gen.var(
|
|
18184
|
+
gen.var(valid15, true);
|
|
18185
18185
|
validateProperties(pat);
|
|
18186
|
-
gen.if(
|
|
18186
|
+
gen.if(valid15);
|
|
18187
18187
|
}
|
|
18188
18188
|
}
|
|
18189
18189
|
}
|
|
@@ -18204,12 +18204,12 @@ var require_patternProperties = __commonJS({
|
|
|
18204
18204
|
schemaProp: pat,
|
|
18205
18205
|
dataProp: key,
|
|
18206
18206
|
dataPropType: util_2.Type.Str
|
|
18207
|
-
},
|
|
18207
|
+
}, valid15);
|
|
18208
18208
|
}
|
|
18209
18209
|
if (it.opts.unevaluated && props !== true) {
|
|
18210
18210
|
gen.assign((0, codegen_1._)`${props}[${key}]`, true);
|
|
18211
18211
|
} else if (!alwaysValid && !it.allErrors) {
|
|
18212
|
-
gen.if((0, codegen_1.not)(
|
|
18212
|
+
gen.if((0, codegen_1.not)(valid15), () => gen.break());
|
|
18213
18213
|
}
|
|
18214
18214
|
});
|
|
18215
18215
|
});
|
|
@@ -18236,14 +18236,14 @@ var require_not = __commonJS({
|
|
|
18236
18236
|
cxt.fail();
|
|
18237
18237
|
return;
|
|
18238
18238
|
}
|
|
18239
|
-
const
|
|
18239
|
+
const valid15 = gen.name("valid");
|
|
18240
18240
|
cxt.subschema({
|
|
18241
18241
|
keyword: "not",
|
|
18242
18242
|
compositeRule: true,
|
|
18243
18243
|
createErrors: false,
|
|
18244
18244
|
allErrors: false
|
|
18245
|
-
},
|
|
18246
|
-
cxt.failResult(
|
|
18245
|
+
}, valid15);
|
|
18246
|
+
cxt.failResult(valid15, () => cxt.reset(), () => cxt.error());
|
|
18247
18247
|
},
|
|
18248
18248
|
error: { message: "must NOT be valid" }
|
|
18249
18249
|
};
|
|
@@ -18291,12 +18291,12 @@ var require_oneOf = __commonJS({
|
|
|
18291
18291
|
if (it.opts.discriminator && parentSchema.discriminator)
|
|
18292
18292
|
return;
|
|
18293
18293
|
const schArr = schema2;
|
|
18294
|
-
const
|
|
18294
|
+
const valid15 = gen.let("valid", false);
|
|
18295
18295
|
const passing = gen.let("passing", null);
|
|
18296
18296
|
const schValid = gen.name("_valid");
|
|
18297
18297
|
cxt.setParams({ passing });
|
|
18298
18298
|
gen.block(validateOneOf);
|
|
18299
|
-
cxt.result(
|
|
18299
|
+
cxt.result(valid15, () => cxt.reset(), () => cxt.error(true));
|
|
18300
18300
|
function validateOneOf() {
|
|
18301
18301
|
schArr.forEach((sch, i) => {
|
|
18302
18302
|
let schCxt;
|
|
@@ -18310,10 +18310,10 @@ var require_oneOf = __commonJS({
|
|
|
18310
18310
|
}, schValid);
|
|
18311
18311
|
}
|
|
18312
18312
|
if (i > 0) {
|
|
18313
|
-
gen.if((0, codegen_1._)`${schValid} && ${
|
|
18313
|
+
gen.if((0, codegen_1._)`${schValid} && ${valid15}`).assign(valid15, false).assign(passing, (0, codegen_1._)`[${passing}, ${i}]`).else();
|
|
18314
18314
|
}
|
|
18315
18315
|
gen.if(schValid, () => {
|
|
18316
|
-
gen.assign(
|
|
18316
|
+
gen.assign(valid15, true);
|
|
18317
18317
|
gen.assign(passing, i);
|
|
18318
18318
|
if (schCxt)
|
|
18319
18319
|
cxt.mergeEvaluated(schCxt, codegen_1.Name);
|
|
@@ -18339,12 +18339,12 @@ var require_allOf = __commonJS({
|
|
|
18339
18339
|
const { gen, schema: schema2, it } = cxt;
|
|
18340
18340
|
if (!Array.isArray(schema2))
|
|
18341
18341
|
throw new Error("ajv implementation error");
|
|
18342
|
-
const
|
|
18342
|
+
const valid15 = gen.name("valid");
|
|
18343
18343
|
schema2.forEach((sch, i) => {
|
|
18344
18344
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
18345
18345
|
return;
|
|
18346
|
-
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i },
|
|
18347
|
-
cxt.ok(
|
|
18346
|
+
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid15);
|
|
18347
|
+
cxt.ok(valid15);
|
|
18348
18348
|
cxt.mergeEvaluated(schCxt);
|
|
18349
18349
|
});
|
|
18350
18350
|
}
|
|
@@ -18378,7 +18378,7 @@ var require_if = __commonJS({
|
|
|
18378
18378
|
const hasElse = hasSchema(it, "else");
|
|
18379
18379
|
if (!hasThen && !hasElse)
|
|
18380
18380
|
return;
|
|
18381
|
-
const
|
|
18381
|
+
const valid15 = gen.let("valid", true);
|
|
18382
18382
|
const schValid = gen.name("_valid");
|
|
18383
18383
|
validateIf();
|
|
18384
18384
|
cxt.reset();
|
|
@@ -18391,7 +18391,7 @@ var require_if = __commonJS({
|
|
|
18391
18391
|
} else {
|
|
18392
18392
|
gen.if((0, codegen_1.not)(schValid), validateClause("else"));
|
|
18393
18393
|
}
|
|
18394
|
-
cxt.pass(
|
|
18394
|
+
cxt.pass(valid15, () => cxt.error(true));
|
|
18395
18395
|
function validateIf() {
|
|
18396
18396
|
const schCxt = cxt.subschema({
|
|
18397
18397
|
keyword: "if",
|
|
@@ -18404,8 +18404,8 @@ var require_if = __commonJS({
|
|
|
18404
18404
|
function validateClause(keyword, ifClause) {
|
|
18405
18405
|
return () => {
|
|
18406
18406
|
const schCxt = cxt.subschema({ keyword }, schValid);
|
|
18407
|
-
gen.assign(
|
|
18408
|
-
cxt.mergeValidEvaluated(schCxt,
|
|
18407
|
+
gen.assign(valid15, schValid);
|
|
18408
|
+
cxt.mergeValidEvaluated(schCxt, valid15);
|
|
18409
18409
|
if (ifClause)
|
|
18410
18410
|
gen.assign(ifClause, (0, codegen_1._)`${keyword}`);
|
|
18411
18411
|
else
|
|
@@ -18680,16 +18680,16 @@ var require_discriminator = __commonJS({
|
|
|
18680
18680
|
throw new Error("discriminator: mapping is not supported");
|
|
18681
18681
|
if (!oneOf)
|
|
18682
18682
|
throw new Error("discriminator: requires oneOf keyword");
|
|
18683
|
-
const
|
|
18683
|
+
const valid15 = gen.let("valid", false);
|
|
18684
18684
|
const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`);
|
|
18685
18685
|
gen.if((0, codegen_1._)`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
|
|
18686
|
-
cxt.ok(
|
|
18686
|
+
cxt.ok(valid15);
|
|
18687
18687
|
function validateMapping() {
|
|
18688
18688
|
const mapping = getMapping();
|
|
18689
18689
|
gen.if(false);
|
|
18690
18690
|
for (const tagValue in mapping) {
|
|
18691
18691
|
gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
|
|
18692
|
-
gen.assign(
|
|
18692
|
+
gen.assign(valid15, applyTagSchema(mapping[tagValue]));
|
|
18693
18693
|
}
|
|
18694
18694
|
gen.else();
|
|
18695
18695
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
|
|
@@ -19421,18 +19421,18 @@ var init_contract = __esm({
|
|
|
19421
19421
|
});
|
|
19422
19422
|
historyParameters = typebox_exports.Object({
|
|
19423
19423
|
action: typebox_exports.Union([typebox_exports.Literal("search"), typebox_exports.Literal("read")], {
|
|
19424
|
-
description: "search \u641C\u7D22\u6216\u5217\
|
|
19424
|
+
description: "search \u641C\u7D22\u6216\u5217\u8868\uFF1Bread \u6309 id \u8BFB\u53D6\u6B63\u6587\u4E0E\u4E0A\u4E0B\u7EA7\u3002\u4EC5\u8BFB\u53D6\u5BF9\u5E94\u52A8\u4F5C\u53C2\u6570\uFF0C\u5176\u4F59\u5FFD\u7565\u3002"
|
|
19425
19425
|
}),
|
|
19426
|
-
host: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\
|
|
19427
|
-
dimension: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\u4EC5 search\
|
|
19428
|
-
query: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1A\u4E0D\u533A\u5206\u5927\u5C0F\u5199\
|
|
19429
|
-
sessionId: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1A\u9650\u5B9A\u5728\u6307\u5B9A\u4F1A\u8BDD ID \u5185\u641C\u7D22\u3002" })),
|
|
19426
|
+
host: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\u6765\u6E90\u5BBF\u4E3B\u7B5B\u9009\uFF08\u5982 pi\u3001dsh\u3001claude\u3001antigravity\u3001codex\u3001qoder\uFF09\uFF1B\u7701\u7565\u67E5\u5168\u90E8\u3002" })),
|
|
19427
|
+
dimension: nullable(typebox_exports.String({ pattern: historyIdentifierPattern.source, description: "\u4EC5 search\uFF1Araw \u4EC5\u539F\u6587\uFF0C\u6216\u6307\u5B9A\u6458\u8981\u7EF4\u5EA6\uFF08\u5982 monthly\u3001session\uFF09\uFF1B\u7701\u7565\u67E5\u5168\u90E8\u3002" })),
|
|
19428
|
+
query: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1A\u8FDE\u7EED\u5173\u952E\u8BCD\uFF08\u4E0D\u533A\u5206\u5927\u5C0F\u5199\uFF09\uFF1B\u7701\u7565\u5217\u4F1A\u8BDD\u6216\u6307\u5B9A\u7EF4\u5EA6\u6458\u8981\u3002" })),
|
|
19429
|
+
sessionId: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1A\u9650\u5B9A\u5728\u6307\u5B9A\u539F\u59CB\u4F1A\u8BDD ID \u5185\u641C\u7D22\u3002" })),
|
|
19430
19430
|
from: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1AISO \u65E5\u671F\u6216\u65F6\u95F4\u4E0B\u754C\u3002" })),
|
|
19431
19431
|
to: nullable(typebox_exports.String({ description: "\u4EC5 search\uFF1AISO \u65E5\u671F\u6216\u65F6\u95F4\u4E0A\u754C\u3002" })),
|
|
19432
|
-
id: nullable(typebox_exports.String({ description: "\u4EC5 read\uFF0C\u5FC5\u586B\
|
|
19433
|
-
offset: nullable(typebox_exports.Integer({ minimum: 0, description: "search\
|
|
19434
|
-
limit: nullable(typebox_exports.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search\uFF1A\
|
|
19435
|
-
childrenOffset: nullable(typebox_exports.Integer({ minimum: 0, description: "\u4EC5 read\uFF1A\u5B50\u8282\u70B9\
|
|
19432
|
+
id: nullable(typebox_exports.String({ description: "\u4EC5 read\uFF0C\u5FC5\u586B\uFF1A\u8282\u70B9 id\uFF08\u6765\u81EA search \u6216\u4E0A\u4E0B\u7EA7\uFF09\u3002" })),
|
|
19433
|
+
offset: nullable(typebox_exports.Integer({ minimum: 0, description: "search \u4E3A\u7ED3\u679C\u504F\u79FB\uFF0Cread \u4E3A\u6B63\u6587\u5B57\u7B26\u504F\u79FB\uFF1B\u9ED8\u8BA4 0\u3002" })),
|
|
19434
|
+
limit: nullable(typebox_exports.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search\uFF1A\u8FD4\u56DE\u6761\u6570\uFF081\u2013${historyPageLimits.search.max}\uFF0C\u9ED8\u8BA4 ${historyPageLimits.search.default}\uFF09\uFF1Bread\uFF1A\u6B63\u6587\u5B57\u7B26\u6570\uFF08\u9ED8\u8BA4 ${historyPageLimits.read.default}\uFF09\u3002` })),
|
|
19435
|
+
childrenOffset: nullable(typebox_exports.Integer({ minimum: 0, description: "\u4EC5 read\uFF1A\u5B50\u8282\u70B9\u504F\u79FB\uFF0C\u9ED8\u8BA4 0\uFF1B\u7EED\u8BFB\u4F20\u4E0A\u6B21 nextChildrenOffset\u3002" }))
|
|
19436
19436
|
}, { additionalProperties: false });
|
|
19437
19437
|
valid2 = schema(historyParameters);
|
|
19438
19438
|
}
|
|
@@ -19509,7 +19509,7 @@ var init_command = __esm({
|
|
|
19509
19509
|
});
|
|
19510
19510
|
|
|
19511
19511
|
// src/extension/cli/index.ts
|
|
19512
|
-
var
|
|
19512
|
+
var import_semver13 = __toESM(require_semver2(), 1);
|
|
19513
19513
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
19514
19514
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
19515
19515
|
|
|
@@ -19537,8 +19537,8 @@ import { lstat, mkdir, readFile, realpath, rmdir } from "node:fs/promises";
|
|
|
19537
19537
|
import { homedir } from "node:os";
|
|
19538
19538
|
import { dirname, join } from "node:path";
|
|
19539
19539
|
import { promisify } from "node:util";
|
|
19540
|
-
async function minimumCliRelease(root
|
|
19541
|
-
const versions =
|
|
19540
|
+
async function minimumCliRelease(root) {
|
|
19541
|
+
const versions = [];
|
|
19542
19542
|
if (process.env.PBOT_PLUGIN_VERSION) versions.push(process.env.PBOT_PLUGIN_VERSION);
|
|
19543
19543
|
for (const prefix of ["", ".pi/npm"]) {
|
|
19544
19544
|
const path = join(root, prefix, "node_modules/personal-bot/package.json");
|
|
@@ -19672,125 +19672,23 @@ async function runUpdatedCli(required, args, input) {
|
|
|
19672
19672
|
return runProgram("npx", ["--yes", "--ignore-scripts", "--prefer-offline", "personal-bot@" + required, ...args], env, false, input);
|
|
19673
19673
|
}
|
|
19674
19674
|
|
|
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
19675
|
// src/extension/cli/index.ts
|
|
19778
19676
|
init_workspace_config2();
|
|
19779
19677
|
|
|
19780
19678
|
// src/extension/cli/args.ts
|
|
19781
19679
|
init_validation();
|
|
19782
|
-
import { homedir as
|
|
19680
|
+
import { homedir as homedir2 } from "node:os";
|
|
19783
19681
|
|
|
19784
19682
|
// src/integrations/installation/workspace.ts
|
|
19785
19683
|
import { stat, realpath as realpath2 } from "node:fs/promises";
|
|
19786
|
-
import { dirname as dirname4, join as
|
|
19684
|
+
import { dirname as dirname4, join as join4, relative, resolve as resolve2 } from "node:path";
|
|
19787
19685
|
async function resolveWorkspace(value, cwd, home) {
|
|
19788
|
-
const path =
|
|
19686
|
+
const path = resolve2(cwd, value === "~" ? home : value.startsWith("~/") ? join4(home, value.slice(2)) : value);
|
|
19789
19687
|
let existing = path;
|
|
19790
19688
|
while (true) {
|
|
19791
19689
|
try {
|
|
19792
19690
|
if (!(await stat(existing)).isDirectory()) throw new Error("\u5DE5\u4F5C\u533A\u6216\u5176\u7236\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A" + existing);
|
|
19793
|
-
return
|
|
19691
|
+
return resolve2(await realpath2(existing), relative(existing, path));
|
|
19794
19692
|
} catch (error) {
|
|
19795
19693
|
if (error.code !== "ENOENT") throw error;
|
|
19796
19694
|
const parent = dirname4(existing);
|
|
@@ -19854,7 +19752,7 @@ function printJson(value, compact) {
|
|
|
19854
19752
|
console.log(JSON.stringify(value, null, compact ? void 0 : 2));
|
|
19855
19753
|
}
|
|
19856
19754
|
function resolveCliWorkspace(workspace, cwd) {
|
|
19857
|
-
return resolveWorkspace(workspace ?? cwd, cwd,
|
|
19755
|
+
return resolveWorkspace(workspace ?? cwd, cwd, homedir2());
|
|
19858
19756
|
}
|
|
19859
19757
|
function requireNoExtraArgs(args, usage) {
|
|
19860
19758
|
if (args.length > 0) throw new CliError(`\u4E0D\u652F\u6301\u7684\u53C2\u6570\uFF1A${args[0]}
|
|
@@ -19978,7 +19876,7 @@ init_validation();
|
|
|
19978
19876
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
19979
19877
|
init_json();
|
|
19980
19878
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
19981
|
-
import { join as
|
|
19879
|
+
import { join as join14 } from "node:path";
|
|
19982
19880
|
async function readManifestVersion(path) {
|
|
19983
19881
|
try {
|
|
19984
19882
|
const data = JSON.parse(await readFile3(path, "utf8"));
|
|
@@ -20000,8 +19898,8 @@ var antigravityInstaller = {
|
|
|
20000
19898
|
detail: "\u672A\u627E\u5230 Antigravity CLI\uFF08agy\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 agy \u540E\u91CD\u8BD5\u3002"
|
|
20001
19899
|
};
|
|
20002
19900
|
}
|
|
20003
|
-
const pluginDir =
|
|
20004
|
-
const bundledVersion = await readManifestVersion(
|
|
19901
|
+
const pluginDir = join14(context.packageRoot, "lib", "antigravity-plugin");
|
|
19902
|
+
const bundledVersion = await readManifestVersion(join14(pluginDir, "plugin.json"));
|
|
20005
19903
|
if (!bundledVersion) {
|
|
20006
19904
|
return {
|
|
20007
19905
|
host: this.host,
|
|
@@ -20032,20 +19930,20 @@ var claudeInstaller = {
|
|
|
20032
19930
|
return {
|
|
20033
19931
|
host: this.host,
|
|
20034
19932
|
state: context.explicit ? "failed" : "skipped",
|
|
20035
|
-
scope: "
|
|
19933
|
+
scope: "project",
|
|
20036
19934
|
detail: "\u672A\u627E\u5230 Claude Code CLI\uFF08claude\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Claude Code \u540E\u91CD\u8BD5\u3002"
|
|
20037
19935
|
};
|
|
20038
19936
|
}
|
|
20039
19937
|
await context.run(
|
|
20040
19938
|
claude,
|
|
20041
|
-
["plugin", "install", "personal-bot", "--marketplace", claudeMarketplace, "--yes"],
|
|
19939
|
+
["plugin", "install", "personal-bot", "--marketplace", claudeMarketplace, "--scope", "project", "--yes"],
|
|
20042
19940
|
context.workspace
|
|
20043
19941
|
);
|
|
20044
19942
|
return {
|
|
20045
19943
|
host: this.host,
|
|
20046
19944
|
state: "installed",
|
|
20047
|
-
scope: "
|
|
20048
|
-
detail: `\u5DF2\u901A\u8FC7 claude plugin install \u4ECE ${claudeMarketplace} \u5B89\u88C5 personal-bot\u3002`,
|
|
19945
|
+
scope: "project",
|
|
19946
|
+
detail: `\u5DF2\u901A\u8FC7 claude plugin install\uFF08project \u4F5C\u7528\u57DF\uFF09\u4ECE ${claudeMarketplace} \u5B89\u88C5 personal-bot\u3002`,
|
|
20049
19947
|
nextStep: "\u5728 Claude Code \u76EE\u6807\u5DE5\u4F5C\u533A\u6267\u884C /personal-bot:pbot init \u542F\u7528 Personal Bot\u3002"
|
|
20050
19948
|
};
|
|
20051
19949
|
}
|
|
@@ -20055,7 +19953,7 @@ var claudeInstaller = {
|
|
|
20055
19953
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
20056
19954
|
init_json();
|
|
20057
19955
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
20058
|
-
import { join as
|
|
19956
|
+
import { join as join15 } from "node:path";
|
|
20059
19957
|
async function readManifestVersion2(path) {
|
|
20060
19958
|
try {
|
|
20061
19959
|
const data = JSON.parse(await readFile4(path, "utf8"));
|
|
@@ -20077,9 +19975,9 @@ var codexInstaller = {
|
|
|
20077
19975
|
detail: "\u672A\u627E\u5230 Codex CLI\uFF08codex\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Codex CLI \u540E\u91CD\u8BD5\u3002"
|
|
20078
19976
|
};
|
|
20079
19977
|
}
|
|
20080
|
-
const marketplaceDir =
|
|
19978
|
+
const marketplaceDir = join15(context.packageRoot, "lib", "codex-marketplace");
|
|
20081
19979
|
const bundledVersion = await readManifestVersion2(
|
|
20082
|
-
|
|
19980
|
+
join15(marketplaceDir, "plugins", "personal-bot", ".codex-plugin", "plugin.json")
|
|
20083
19981
|
);
|
|
20084
19982
|
if (!bundledVersion) {
|
|
20085
19983
|
return {
|
|
@@ -20159,7 +20057,7 @@ var piInstaller = {
|
|
|
20159
20057
|
var import_semver4 = __toESM(require_semver2(), 1);
|
|
20160
20058
|
init_json();
|
|
20161
20059
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
20162
|
-
import { join as
|
|
20060
|
+
import { join as join16 } from "node:path";
|
|
20163
20061
|
async function readManifestVersion3(path) {
|
|
20164
20062
|
try {
|
|
20165
20063
|
const data = JSON.parse(await readFile5(path, "utf8"));
|
|
@@ -20177,27 +20075,27 @@ var qoderInstaller = {
|
|
|
20177
20075
|
return {
|
|
20178
20076
|
host: this.host,
|
|
20179
20077
|
state: context.explicit ? "failed" : "skipped",
|
|
20180
|
-
scope: "
|
|
20078
|
+
scope: "project",
|
|
20181
20079
|
detail: "\u672A\u627E\u5230 Qoder CLI\uFF08qodercli\uFF09\u3002\u8BF7\u5148\u5B89\u88C5 Qoder CLI \u540E\u91CD\u8BD5\u3002"
|
|
20182
20080
|
};
|
|
20183
20081
|
}
|
|
20184
|
-
const pluginDir =
|
|
20185
|
-
const bundledVersion = await readManifestVersion3(
|
|
20082
|
+
const pluginDir = join16(context.packageRoot, "lib", "qoder-plugin");
|
|
20083
|
+
const bundledVersion = await readManifestVersion3(join16(pluginDir, ".qoder-plugin", "plugin.json"));
|
|
20186
20084
|
if (!bundledVersion) {
|
|
20187
20085
|
return {
|
|
20188
20086
|
host: this.host,
|
|
20189
20087
|
state: "failed",
|
|
20190
|
-
scope: "
|
|
20088
|
+
scope: "project",
|
|
20191
20089
|
detail: `\u7F3A\u5C11 Qoder CLI \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}\u3002\u8BF7\u5148\u8FD0\u884C npm run build\u3002`
|
|
20192
20090
|
};
|
|
20193
20091
|
}
|
|
20194
|
-
await context.run(qodercli, ["plugin", "install", pluginDir], context.workspace);
|
|
20092
|
+
await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", "project"], context.workspace);
|
|
20195
20093
|
return {
|
|
20196
20094
|
host: this.host,
|
|
20197
20095
|
state: "installed",
|
|
20198
20096
|
version: bundledVersion,
|
|
20199
|
-
scope: "
|
|
20200
|
-
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install \u5B89\u88C5 Qoder CLI \u63D2\u4EF6\uFF08${bundledVersion}\uFF09\u3002`,
|
|
20097
|
+
scope: "project",
|
|
20098
|
+
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install\uFF08project \u4F5C\u7528\u57DF\uFF09\u5B89\u88C5 Qoder CLI \u63D2\u4EF6\uFF08${bundledVersion}\uFF09\u3002`,
|
|
20201
20099
|
nextStep: "\u5728\u76EE\u6807\u5DE5\u4F5C\u533A\u6267\u884C pbot plugin qoder init \u542F\u7528 Personal Bot\u3002"
|
|
20202
20100
|
};
|
|
20203
20101
|
}
|
|
@@ -20239,11 +20137,11 @@ var listHostInstallers = () => hostInstallers.list();
|
|
|
20239
20137
|
import { spawn as spawn2 } from "node:child_process";
|
|
20240
20138
|
import { access, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
20241
20139
|
import { constants as constants3 } from "node:fs";
|
|
20242
|
-
import { delimiter as delimiter2, isAbsolute as
|
|
20140
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute2, resolve as resolve7 } from "node:path";
|
|
20243
20141
|
async function findExecutable(name, env = process.env) {
|
|
20244
20142
|
const directories2 = (env.PATH ?? "").split(delimiter2).filter(Boolean);
|
|
20245
20143
|
for (const directory of directories2) {
|
|
20246
|
-
const path =
|
|
20144
|
+
const path = resolve7(directory, name);
|
|
20247
20145
|
if (name === "pi" && path.split(/[\\/]/).includes("_npx")) continue;
|
|
20248
20146
|
try {
|
|
20249
20147
|
await access(path, constants3.X_OK);
|
|
@@ -20264,7 +20162,7 @@ var SetupProcesses = class {
|
|
|
20264
20162
|
}
|
|
20265
20163
|
async run(command, args, cwd, options = {}) {
|
|
20266
20164
|
this.signal.throwIfAborted();
|
|
20267
|
-
if (!
|
|
20165
|
+
if (!isAbsolute2(cwd)) throw new Error("\u8FDB\u7A0B\u5DE5\u4F5C\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20268
20166
|
const interactive = options.interactive ?? false;
|
|
20269
20167
|
const timeoutMs = options.timeoutMs ?? (interactive ? 15 * 6e4 : 6e4);
|
|
20270
20168
|
return new Promise((resolveResult, reject) => {
|
|
@@ -20481,7 +20379,7 @@ var installCommand = {
|
|
|
20481
20379
|
init_paths();
|
|
20482
20380
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
20483
20381
|
import { existsSync as existsSync2 } from "node:fs";
|
|
20484
|
-
import { join as
|
|
20382
|
+
import { join as join19 } from "node:path";
|
|
20485
20383
|
|
|
20486
20384
|
// src/integrations/hosts/plugin-registry.ts
|
|
20487
20385
|
init_validation();
|
|
@@ -20491,7 +20389,7 @@ init_json();
|
|
|
20491
20389
|
init_paths();
|
|
20492
20390
|
init_validation();
|
|
20493
20391
|
import { readFile as readFile6, realpath as realpath4, stat as stat4 } from "node:fs/promises";
|
|
20494
|
-
import { dirname as dirname6, isAbsolute as
|
|
20392
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, relative as relative3, resolve as resolve8, sep } from "node:path";
|
|
20495
20393
|
var supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
|
|
20496
20394
|
function cleanUserRequest(content) {
|
|
20497
20395
|
const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
@@ -20541,7 +20439,7 @@ function projectAntigravityTranscript(sessionId, content, terminationReason) {
|
|
|
20541
20439
|
return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
|
|
20542
20440
|
}
|
|
20543
20441
|
async function readAntigravityTranscript(transcriptPath) {
|
|
20544
|
-
const fullPath =
|
|
20442
|
+
const fullPath = join17(dirname6(transcriptPath), "transcript_full.jsonl");
|
|
20545
20443
|
for (const path of [fullPath, transcriptPath]) {
|
|
20546
20444
|
try {
|
|
20547
20445
|
return await readFile6(path, "utf8");
|
|
@@ -20558,10 +20456,10 @@ function workspaceFromPayload(cwd, payload) {
|
|
|
20558
20456
|
}
|
|
20559
20457
|
return cwd;
|
|
20560
20458
|
}
|
|
20561
|
-
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT ||
|
|
20562
|
-
const skillsRoot =
|
|
20563
|
-
const rel = relative3(skillsRoot,
|
|
20564
|
-
if (!rel || rel.startsWith("..") ||
|
|
20459
|
+
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve8(resourceRoot, "..")) {
|
|
20460
|
+
const skillsRoot = resolve8(pluginRoot, "skills");
|
|
20461
|
+
const rel = relative3(skillsRoot, resolve8(targetPath));
|
|
20462
|
+
if (!rel || rel.startsWith("..") || isAbsolute3(rel)) return void 0;
|
|
20565
20463
|
const skill = rel.split(sep)[0];
|
|
20566
20464
|
if (!skill || skill === "pbot") return void 0;
|
|
20567
20465
|
return skill;
|
|
@@ -20571,7 +20469,7 @@ function isPreToolUse(payload) {
|
|
|
20571
20469
|
}
|
|
20572
20470
|
async function antigravityWorkspaceRoot(cwd, payload) {
|
|
20573
20471
|
const directory = workspaceFromPayload(cwd, payload);
|
|
20574
|
-
requireThat(
|
|
20472
|
+
requireThat(isAbsolute3(directory), "Antigravity \u5DE5\u4F5C\u533A\u9700\u8981\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20575
20473
|
const root = await realpath4(directory);
|
|
20576
20474
|
requireThat((await stat4(root)).isDirectory(), "Antigravity \u5DE5\u4F5C\u533A\u9700\u8981\u76EE\u5F55\u3002");
|
|
20577
20475
|
return root;
|
|
@@ -20648,9 +20546,9 @@ init_validation();
|
|
|
20648
20546
|
init_json();
|
|
20649
20547
|
init_validation();
|
|
20650
20548
|
import { realpath as realpath5, stat as stat5 } from "node:fs/promises";
|
|
20651
|
-
import { isAbsolute as
|
|
20549
|
+
import { isAbsolute as isAbsolute4 } from "node:path";
|
|
20652
20550
|
async function pluginWorkspaceRoot(directory) {
|
|
20653
|
-
requireThat(
|
|
20551
|
+
requireThat(isAbsolute4(directory), "\u63D2\u4EF6\u5DE5\u4F5C\u533A\u9700\u8981\u7EDD\u5BF9\u8DEF\u5F84\u3002");
|
|
20654
20552
|
const root = await realpath5(directory);
|
|
20655
20553
|
requireThat((await stat5(root)).isDirectory(), "\u63D2\u4EF6\u5DE5\u4F5C\u533A\u9700\u8981\u76EE\u5F55\u3002");
|
|
20656
20554
|
return root;
|
|
@@ -20814,7 +20712,7 @@ init_json();
|
|
|
20814
20712
|
init_validation();
|
|
20815
20713
|
init_atomic_json();
|
|
20816
20714
|
import { mkdir as mkdir3, readFile as readFile7 } from "node:fs/promises";
|
|
20817
|
-
import { dirname as dirname7, join as
|
|
20715
|
+
import { dirname as dirname7, join as join18, resolve as resolve9 } from "node:path";
|
|
20818
20716
|
var serverNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
20819
20717
|
var reservedServerNames = /* @__PURE__ */ new Set(["pbot"]);
|
|
20820
20718
|
var stdioKeys = /* @__PURE__ */ new Set(["command", "args", "env", "cwd", "description", "timeout", "enabled"]);
|
|
@@ -20920,7 +20818,7 @@ function validateMcpFile(value) {
|
|
|
20920
20818
|
return { ...value, mcpServers: servers };
|
|
20921
20819
|
}
|
|
20922
20820
|
function workspaceMcpPath(root) {
|
|
20923
|
-
return
|
|
20821
|
+
return join18(root, ".pbot", "mcp.json");
|
|
20924
20822
|
}
|
|
20925
20823
|
async function readWorkspaceMcpConfig(root) {
|
|
20926
20824
|
const path = workspaceMcpPath(root);
|
|
@@ -20969,7 +20867,7 @@ async function removeWorkspaceMcpServer(root, name) {
|
|
|
20969
20867
|
// src/extension/cli/commands/mcp.ts
|
|
20970
20868
|
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\u65E0\u53C2\u6570\u65F6\u542F\u52A8\u7EDF\u4E00 stdio MCP \u670D\u52A1\uFF08\u66B4\u9732 worker_* \u4E0E workspace_mcp_*\uFF09\uFF1B\u5E26 list/add/remove \u65F6\u7BA1\u7406\u5DE5\u4F5C\u533A .pbot/mcp.json\u3002";
|
|
20971
20869
|
async function runMcpServer() {
|
|
20972
|
-
const entry =
|
|
20870
|
+
const entry = join19(packageRoot, "lib/extension/mcp.js");
|
|
20973
20871
|
if (!existsSync2(entry)) {
|
|
20974
20872
|
console.error("\u7F3A\u5C11 MCP \u6784\u5EFA\u4EA7\u7269\uFF1A" + entry + "\u3002\u8BF7\u5148\u8FD0\u884C npm run build\u3002");
|
|
20975
20873
|
return 1;
|
|
@@ -21123,14 +21021,14 @@ init_validation();
|
|
|
21123
21021
|
|
|
21124
21022
|
// src/extension/hosts/plugin-runtime.ts
|
|
21125
21023
|
init_paths();
|
|
21126
|
-
import { join as
|
|
21024
|
+
import { join as join23 } from "node:path";
|
|
21127
21025
|
init_validation();
|
|
21128
21026
|
|
|
21129
21027
|
// src/integrations/agent-resources.ts
|
|
21130
21028
|
init_paths();
|
|
21131
21029
|
init_validation();
|
|
21132
21030
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
21133
|
-
import { join as
|
|
21031
|
+
import { join as join20 } from "node:path";
|
|
21134
21032
|
async function readOptionalFile(path) {
|
|
21135
21033
|
try {
|
|
21136
21034
|
return await readFile8(path, "utf8");
|
|
@@ -21140,14 +21038,14 @@ async function readOptionalFile(path) {
|
|
|
21140
21038
|
}
|
|
21141
21039
|
}
|
|
21142
21040
|
async function readLocalRole(agent, root) {
|
|
21143
|
-
const local = await readOptionalFile(
|
|
21041
|
+
const local = await readOptionalFile(join20(root, "agents", agent + ".md"));
|
|
21144
21042
|
return local.trim() ? "\u5DE5\u4F5C\u533A\u804C\u8D23\u8865\u5145\uFF1A\n" + local : "";
|
|
21145
21043
|
}
|
|
21146
21044
|
async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md") {
|
|
21147
21045
|
requireThat(agent === "coordinator" || agent === "general-purpose", "\u672A\u77E5\u804C\u8D23\u3002");
|
|
21148
|
-
let text = await readFile8(
|
|
21046
|
+
let text = await readFile8(join20(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
21149
21047
|
if (agent === "coordinator") {
|
|
21150
|
-
text += "\n\n" + await readFile8(
|
|
21048
|
+
text += "\n\n" + await readFile8(join20(resourceRoot, "prompts", coordinatorPrompt), "utf8");
|
|
21151
21049
|
}
|
|
21152
21050
|
const local = await readLocalRole(agent, root);
|
|
21153
21051
|
if (local) text += "\n\n" + local;
|
|
@@ -21157,7 +21055,7 @@ async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md
|
|
|
21157
21055
|
function formatWorkspaceSkills(skills) {
|
|
21158
21056
|
if (!skills.length) return "";
|
|
21159
21057
|
const lines = skills.map((skill) => `- **${skill.name}**\uFF08\`${skill.path}\`\uFF09\uFF1A${skill.description}`);
|
|
21160
|
-
return "## \
|
|
21058
|
+
return "## \u53EF\u7528\u6280\u80FD\n\n\u4EFB\u52A1\u5339\u914D\u65F6\u6309\u9700\u8BFB\u53D6\u5BF9\u5E94 `SKILL.md` \u6B63\u6587\uFF1A\n" + lines.join("\n");
|
|
21161
21059
|
}
|
|
21162
21060
|
async function loadWorkspaceContext(options) {
|
|
21163
21061
|
const {
|
|
@@ -21172,12 +21070,12 @@ async function loadWorkspaceContext(options) {
|
|
|
21172
21070
|
notices = []
|
|
21173
21071
|
} = options;
|
|
21174
21072
|
const [workspace, roleText, rootAgents] = includePrompts ? await Promise.all([
|
|
21175
|
-
readFile8(
|
|
21073
|
+
readFile8(join20(resourceRoot, "prompts/workspace.md"), "utf8"),
|
|
21176
21074
|
localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
|
|
21177
|
-
includeRootAgents ? readOptionalFile(
|
|
21075
|
+
includeRootAgents ? readOptionalFile(join20(root, "AGENTS.md")) : Promise.resolve("")
|
|
21178
21076
|
]) : ["", "", ""];
|
|
21179
21077
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
21180
|
-
const noticesSection = notices.length ? "## \u542F\u52A8\u63D0\u793A\n\n" + notices.map((item) => `- ${item}`).join("\n") : "";
|
|
21078
|
+
const noticesSection = notices.length ? "## \u542F\u52A8\u63D0\u793A\n\n\u4EE5\u4E0B\u4E3A\u5DE5\u4F5C\u533A\u7EF4\u62A4\u63D0\u9192\uFF0C\u9002\u65F6\u987A\u5E26\u544A\u77E5\u7528\u6237\u5373\u53EF\uFF0C\u52FF\u672A\u7ECF\u7528\u6237\u8981\u6C42\u81EA\u884C\u6267\u884C\uFF1A\n" + notices.map((item) => `- ${item}`).join("\n") : "";
|
|
21181
21079
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
21182
21080
|
const text = [
|
|
21183
21081
|
workspace,
|
|
@@ -21287,7 +21185,7 @@ init_validation();
|
|
|
21287
21185
|
init_paths();
|
|
21288
21186
|
init_workspace_config2();
|
|
21289
21187
|
import { lstat as lstat2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
21290
|
-
import { join as
|
|
21188
|
+
import { join as join21 } from "node:path";
|
|
21291
21189
|
async function initializeWorkspace(root) {
|
|
21292
21190
|
const configuration = await readWorkspaceConfig(root);
|
|
21293
21191
|
if (configuration.error) throw new Error(configuration.error);
|
|
@@ -21297,22 +21195,22 @@ async function initializeWorkspace(root) {
|
|
|
21297
21195
|
var directories = ["areas", "projects", "knowledge", "providers", "scratch", "agents"];
|
|
21298
21196
|
async function prepareWorkspace(root) {
|
|
21299
21197
|
for (const part of directories) {
|
|
21300
|
-
const path =
|
|
21198
|
+
const path = join21(root, part);
|
|
21301
21199
|
await mkdir4(path, { mode: 448 }).catch((error) => {
|
|
21302
21200
|
if (error.code !== "EEXIST") throw error;
|
|
21303
21201
|
});
|
|
21304
21202
|
const entry = await lstat2(path);
|
|
21305
21203
|
requireThat(entry.isDirectory() && !entry.isSymbolicLink(), "\u5DE5\u4F5C\u533A\u76EE\u5F55\u4E0D\u80FD\u4F7F\u7528\u7B26\u53F7\u94FE\u63A5\uFF1A" + path);
|
|
21306
21204
|
}
|
|
21307
|
-
const agents = await readFile9(
|
|
21308
|
-
await writeFile2(
|
|
21205
|
+
const agents = await readFile9(join21(resourceRoot, "templates/workspace-agents.md"), "utf8");
|
|
21206
|
+
await writeFile2(join21(root, "AGENTS.md"), agents, { flag: "wx" }).catch((error) => {
|
|
21309
21207
|
if (error.code !== "EEXIST") throw error;
|
|
21310
21208
|
});
|
|
21311
21209
|
}
|
|
21312
21210
|
|
|
21313
21211
|
// src/services/workspace/workspace-skills.ts
|
|
21314
21212
|
import { readdir, readFile as readFile10 } from "node:fs/promises";
|
|
21315
|
-
import { join as
|
|
21213
|
+
import { join as join22 } from "node:path";
|
|
21316
21214
|
function unquoteYaml(value) {
|
|
21317
21215
|
const trimmed = value.trim();
|
|
21318
21216
|
if (trimmed.length >= 2 && (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
@@ -21360,7 +21258,7 @@ function parseSkillFrontmatter(content) {
|
|
|
21360
21258
|
};
|
|
21361
21259
|
}
|
|
21362
21260
|
async function discoverWorkspaceSkills(root) {
|
|
21363
|
-
return discoverSkills(
|
|
21261
|
+
return discoverSkills(join22(root, ".agents", "skills"), ".agents/skills");
|
|
21364
21262
|
}
|
|
21365
21263
|
async function discoverSkills(skillsDir, indexPath) {
|
|
21366
21264
|
let entries;
|
|
@@ -21373,7 +21271,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21373
21271
|
const results = [];
|
|
21374
21272
|
for (const entry of entries) {
|
|
21375
21273
|
if (entry.name.startsWith(".") || !entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
21376
|
-
const filePath =
|
|
21274
|
+
const filePath = join22(skillsDir, entry.name, "SKILL.md");
|
|
21377
21275
|
let content;
|
|
21378
21276
|
try {
|
|
21379
21277
|
content = await readFile10(filePath, "utf8");
|
|
@@ -21385,7 +21283,7 @@ async function discoverSkills(skillsDir, indexPath) {
|
|
|
21385
21283
|
results.push({
|
|
21386
21284
|
name: meta.name,
|
|
21387
21285
|
description: meta.description,
|
|
21388
|
-
path:
|
|
21286
|
+
path: join22(indexPath, entry.name, "SKILL.md")
|
|
21389
21287
|
});
|
|
21390
21288
|
}
|
|
21391
21289
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -21402,7 +21300,6 @@ async function pluginCommand(adapter, args, cwd) {
|
|
|
21402
21300
|
requireThat(["init", "status"].includes(action), adapter.usage);
|
|
21403
21301
|
if (action === "init") {
|
|
21404
21302
|
await initializeWorkspace(root);
|
|
21405
|
-
bindWorkspacePlugin(root, adapter.host, process.env.PBOT_PLUGIN_MANIFEST || process.env.PBOT_PLUGIN_VERSION);
|
|
21406
21303
|
}
|
|
21407
21304
|
const configuration = await readWorkspaceConfig(root);
|
|
21408
21305
|
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
|
|
@@ -21436,7 +21333,6 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21436
21333
|
return adapter.formatPass(payload);
|
|
21437
21334
|
}
|
|
21438
21335
|
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
21336
|
if (features.history && adapter.extractHistory) {
|
|
21441
21337
|
try {
|
|
21442
21338
|
const capture = await adapter.extractHistory(event);
|
|
@@ -21449,17 +21345,10 @@ async function pluginHook(adapter, payload, replay) {
|
|
|
21449
21345
|
const includeSkills = features.skills && !event.noticesOnly;
|
|
21450
21346
|
const workspaceSkills = includeSkills && !adapter.nativeWorkspaceSkills ? await discoverWorkspaceSkills(root) : [];
|
|
21451
21347
|
if (includeSkills && adapter.indexBundledSkills) {
|
|
21452
|
-
const directory =
|
|
21348
|
+
const directory = join23(resourceRoot, "skills");
|
|
21453
21349
|
workspaceSkills.push(...await discoverSkills(directory, directory));
|
|
21454
21350
|
}
|
|
21455
21351
|
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
21352
|
if (!includePrompts && !workspaceSkills.length && !notices.length) return adapter.formatPass(payload);
|
|
21464
21353
|
const context = await loadWorkspaceContext({
|
|
21465
21354
|
host: adapter.host,
|
|
@@ -21507,10 +21396,7 @@ var pluginCommand2 = {
|
|
|
21507
21396
|
};
|
|
21508
21397
|
|
|
21509
21398
|
// 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";
|
|
21399
|
+
import { join as join28 } from "node:path";
|
|
21514
21400
|
|
|
21515
21401
|
// src/common/package-source.ts
|
|
21516
21402
|
var import_semver5 = __toESM(require_semver2(), 1);
|
|
@@ -21535,7 +21421,7 @@ init_validation();
|
|
|
21535
21421
|
var import_semver6 = __toESM(require_semver2(), 1);
|
|
21536
21422
|
init_json();
|
|
21537
21423
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
21538
|
-
import { join as
|
|
21424
|
+
import { join as join24 } from "node:path";
|
|
21539
21425
|
async function readManifestVersion4(path) {
|
|
21540
21426
|
try {
|
|
21541
21427
|
const data = JSON.parse(await readFile11(path, "utf8"));
|
|
@@ -21545,26 +21431,67 @@ async function readManifestVersion4(path) {
|
|
|
21545
21431
|
throw error;
|
|
21546
21432
|
}
|
|
21547
21433
|
}
|
|
21434
|
+
function parsePluginList(raw) {
|
|
21435
|
+
const parsed = JSON.parse(raw);
|
|
21436
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21437
|
+
const entries = [];
|
|
21438
|
+
for (const item of items) {
|
|
21439
|
+
if (!object(item) || typeof item.name !== "string") continue;
|
|
21440
|
+
entries.push({
|
|
21441
|
+
name: item.name,
|
|
21442
|
+
...typeof item.version === "string" ? { version: item.version } : {}
|
|
21443
|
+
});
|
|
21444
|
+
}
|
|
21445
|
+
return entries;
|
|
21446
|
+
}
|
|
21548
21447
|
var antigravityUpgrader = {
|
|
21549
21448
|
host: "antigravity",
|
|
21550
21449
|
async upgrade(context) {
|
|
21551
|
-
|
|
21450
|
+
const agy = context.env.PBOT_AGY_COMMAND || await context.findExecutable("agy");
|
|
21451
|
+
if (!agy) {
|
|
21452
|
+
return {
|
|
21453
|
+
host: this.host,
|
|
21454
|
+
state: "skipped",
|
|
21455
|
+
detail: "\u672A\u627E\u5230 Antigravity CLI\uFF08agy\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21456
|
+
};
|
|
21457
|
+
}
|
|
21458
|
+
let entries;
|
|
21459
|
+
try {
|
|
21460
|
+
const raw = await context.run(agy, ["plugin", "list", "--json"], context.workspace);
|
|
21461
|
+
entries = parsePluginList(raw);
|
|
21462
|
+
} catch (error) {
|
|
21463
|
+
return {
|
|
21464
|
+
host: this.host,
|
|
21465
|
+
state: "failed",
|
|
21466
|
+
detail: `\u67E5\u8BE2 Antigravity \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21467
|
+
};
|
|
21468
|
+
}
|
|
21469
|
+
const entry = entries.find((item) => item.name === "personal-bot");
|
|
21470
|
+
if (!entry) {
|
|
21471
|
+
return {
|
|
21472
|
+
host: this.host,
|
|
21473
|
+
state: "skipped",
|
|
21474
|
+
detail: "\u672A\u5728 Antigravity \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21475
|
+
};
|
|
21476
|
+
}
|
|
21477
|
+
const installedVersion = entry.version;
|
|
21478
|
+
if (installedVersion && (0, import_semver6.valid)(installedVersion) && (0, import_semver6.gte)(installedVersion, context.targetVersion)) {
|
|
21552
21479
|
return {
|
|
21553
21480
|
host: this.host,
|
|
21554
21481
|
state: "up-to-date",
|
|
21555
|
-
previousVersion:
|
|
21556
|
-
version:
|
|
21482
|
+
previousVersion: installedVersion,
|
|
21483
|
+
version: installedVersion,
|
|
21557
21484
|
scope: "user",
|
|
21558
21485
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21559
21486
|
};
|
|
21560
21487
|
}
|
|
21561
|
-
const pluginDir =
|
|
21562
|
-
const bundledVersion = await readManifestVersion4(
|
|
21488
|
+
const pluginDir = join24(context.packageRoot, "lib", "antigravity-plugin");
|
|
21489
|
+
const bundledVersion = await readManifestVersion4(join24(pluginDir, "plugin.json"));
|
|
21563
21490
|
if (!bundledVersion) {
|
|
21564
21491
|
return {
|
|
21565
21492
|
host: this.host,
|
|
21566
21493
|
state: "skipped",
|
|
21567
|
-
...
|
|
21494
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21568
21495
|
detail: `\u7F3A\u5C11 Antigravity \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}`
|
|
21569
21496
|
};
|
|
21570
21497
|
}
|
|
@@ -21572,24 +21499,15 @@ var antigravityUpgrader = {
|
|
|
21572
21499
|
return {
|
|
21573
21500
|
host: this.host,
|
|
21574
21501
|
state: "skipped",
|
|
21575
|
-
...
|
|
21502
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21576
21503
|
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
21504
|
};
|
|
21578
21505
|
}
|
|
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
21506
|
await context.run(agy, ["plugin", "install", pluginDir], context.workspace);
|
|
21589
21507
|
return {
|
|
21590
21508
|
host: this.host,
|
|
21591
21509
|
state: "updated",
|
|
21592
|
-
...
|
|
21510
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21593
21511
|
version: bundledVersion,
|
|
21594
21512
|
scope: "user",
|
|
21595
21513
|
detail: `\u5DF2\u901A\u8FC7 agy plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
@@ -21602,7 +21520,7 @@ var antigravityUpgrader = {
|
|
|
21602
21520
|
var import_semver7 = __toESM(require_semver2(), 1);
|
|
21603
21521
|
init_json();
|
|
21604
21522
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
21605
|
-
function
|
|
21523
|
+
function parsePluginList2(raw) {
|
|
21606
21524
|
const parsed = JSON.parse(raw);
|
|
21607
21525
|
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21608
21526
|
const entries = [];
|
|
@@ -21650,19 +21568,17 @@ var claudeUpgrader = {
|
|
|
21650
21568
|
return {
|
|
21651
21569
|
host: this.host,
|
|
21652
21570
|
state: "skipped",
|
|
21653
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21654
21571
|
detail: "\u672A\u627E\u5230 Claude Code CLI\uFF08claude\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21655
21572
|
};
|
|
21656
21573
|
}
|
|
21657
21574
|
let entries;
|
|
21658
21575
|
try {
|
|
21659
21576
|
const raw = await context.run(claude, ["plugin", "list", "--json"], context.workspace);
|
|
21660
|
-
entries =
|
|
21577
|
+
entries = parsePluginList2(raw);
|
|
21661
21578
|
} catch (error) {
|
|
21662
21579
|
return {
|
|
21663
21580
|
host: this.host,
|
|
21664
21581
|
state: "failed",
|
|
21665
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21666
21582
|
detail: `\u67E5\u8BE2 Claude \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21667
21583
|
};
|
|
21668
21584
|
}
|
|
@@ -21671,11 +21587,10 @@ var claudeUpgrader = {
|
|
|
21671
21587
|
return {
|
|
21672
21588
|
host: this.host,
|
|
21673
21589
|
state: "skipped",
|
|
21674
|
-
...context.currentVersion ? { previousVersion: context.currentVersion } : {},
|
|
21675
21590
|
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
21591
|
};
|
|
21677
21592
|
}
|
|
21678
|
-
const installedVersion = entry.version
|
|
21593
|
+
const installedVersion = entry.version;
|
|
21679
21594
|
const scope = entry.scope ?? "user";
|
|
21680
21595
|
if (installedVersion && (0, import_semver7.valid)(installedVersion) && (0, import_semver7.gte)(installedVersion, context.targetVersion)) {
|
|
21681
21596
|
return {
|
|
@@ -21714,7 +21629,7 @@ var claudeUpgrader = {
|
|
|
21714
21629
|
var import_semver8 = __toESM(require_semver2(), 1);
|
|
21715
21630
|
init_json();
|
|
21716
21631
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
21717
|
-
import { join as
|
|
21632
|
+
import { join as join25 } from "node:path";
|
|
21718
21633
|
async function readManifestVersion5(path) {
|
|
21719
21634
|
try {
|
|
21720
21635
|
const data = JSON.parse(await readFile12(path, "utf8"));
|
|
@@ -21724,26 +21639,82 @@ async function readManifestVersion5(path) {
|
|
|
21724
21639
|
throw error;
|
|
21725
21640
|
}
|
|
21726
21641
|
}
|
|
21642
|
+
function parsePluginList3(raw) {
|
|
21643
|
+
const parsed = JSON.parse(raw);
|
|
21644
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.installed) ? parsed.installed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21645
|
+
const entries = [];
|
|
21646
|
+
for (const item of items) {
|
|
21647
|
+
if (!object(item)) continue;
|
|
21648
|
+
const id = typeof item.pluginId === "string" ? item.pluginId : typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : void 0;
|
|
21649
|
+
if (!id) continue;
|
|
21650
|
+
entries.push({
|
|
21651
|
+
id,
|
|
21652
|
+
...typeof item.name === "string" ? { name: item.name } : {},
|
|
21653
|
+
...typeof item.version === "string" ? { version: item.version } : {},
|
|
21654
|
+
...typeof item.installed === "boolean" ? { installed: item.installed } : {}
|
|
21655
|
+
});
|
|
21656
|
+
}
|
|
21657
|
+
return entries;
|
|
21658
|
+
}
|
|
21659
|
+
function isMissingMarketplaceError(error) {
|
|
21660
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
21661
|
+
return /marketplace.*(not found|unknown|does not exist|not configured)|unknown marketplace/i.test(message);
|
|
21662
|
+
}
|
|
21727
21663
|
var codexUpgrader = {
|
|
21728
21664
|
host: "codex",
|
|
21729
21665
|
async upgrade(context) {
|
|
21730
|
-
|
|
21666
|
+
const codex = context.env.PBOT_CODEX_COMMAND || await context.findExecutable("codex");
|
|
21667
|
+
if (!codex) {
|
|
21668
|
+
return {
|
|
21669
|
+
host: this.host,
|
|
21670
|
+
state: "skipped",
|
|
21671
|
+
detail: "\u672A\u627E\u5230 Codex CLI\uFF08codex\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21672
|
+
};
|
|
21673
|
+
}
|
|
21674
|
+
let entries;
|
|
21675
|
+
try {
|
|
21676
|
+
const raw = await context.run(codex, ["plugin", "list", "-m", "pbot-local", "--json"], context.workspace);
|
|
21677
|
+
entries = parsePluginList3(raw);
|
|
21678
|
+
} catch (error) {
|
|
21679
|
+
if (isMissingMarketplaceError(error)) {
|
|
21680
|
+
return {
|
|
21681
|
+
host: this.host,
|
|
21682
|
+
state: "skipped",
|
|
21683
|
+
detail: "\u672A\u5728 Codex \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21684
|
+
};
|
|
21685
|
+
}
|
|
21686
|
+
return {
|
|
21687
|
+
host: this.host,
|
|
21688
|
+
state: "failed",
|
|
21689
|
+
detail: `\u67E5\u8BE2 Codex \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21690
|
+
};
|
|
21691
|
+
}
|
|
21692
|
+
const entry = entries.find((item) => item.installed !== false && (item.name === "personal-bot" || item.id === "personal-bot" || item.id.startsWith("personal-bot@")));
|
|
21693
|
+
if (!entry) {
|
|
21694
|
+
return {
|
|
21695
|
+
host: this.host,
|
|
21696
|
+
state: "skipped",
|
|
21697
|
+
detail: "\u672A\u5728 Codex \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21698
|
+
};
|
|
21699
|
+
}
|
|
21700
|
+
const installedVersion = entry.version;
|
|
21701
|
+
if (installedVersion && (0, import_semver8.valid)(installedVersion) && (0, import_semver8.gte)(installedVersion, context.targetVersion)) {
|
|
21731
21702
|
return {
|
|
21732
21703
|
host: this.host,
|
|
21733
21704
|
state: "up-to-date",
|
|
21734
|
-
previousVersion:
|
|
21735
|
-
version:
|
|
21705
|
+
previousVersion: installedVersion,
|
|
21706
|
+
version: installedVersion,
|
|
21736
21707
|
scope: "user",
|
|
21737
21708
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21738
21709
|
};
|
|
21739
21710
|
}
|
|
21740
|
-
const marketplaceDir =
|
|
21741
|
-
const bundledVersion = await readManifestVersion5(
|
|
21711
|
+
const marketplaceDir = join25(context.packageRoot, "lib", "codex-marketplace");
|
|
21712
|
+
const bundledVersion = await readManifestVersion5(join25(marketplaceDir, "plugins", "personal-bot", ".codex-plugin", "plugin.json"));
|
|
21742
21713
|
if (!bundledVersion) {
|
|
21743
21714
|
return {
|
|
21744
21715
|
host: this.host,
|
|
21745
21716
|
state: "skipped",
|
|
21746
|
-
...
|
|
21717
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21747
21718
|
detail: `\u7F3A\u5C11 Codex \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${marketplaceDir}`
|
|
21748
21719
|
};
|
|
21749
21720
|
}
|
|
@@ -21751,19 +21722,10 @@ var codexUpgrader = {
|
|
|
21751
21722
|
return {
|
|
21752
21723
|
host: this.host,
|
|
21753
21724
|
state: "skipped",
|
|
21754
|
-
...
|
|
21725
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21755
21726
|
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
21727
|
};
|
|
21757
21728
|
}
|
|
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
21729
|
try {
|
|
21768
21730
|
await context.run(codex, ["plugin", "marketplace", "add", marketplaceDir], context.workspace);
|
|
21769
21731
|
} catch {
|
|
@@ -21772,7 +21734,7 @@ var codexUpgrader = {
|
|
|
21772
21734
|
return {
|
|
21773
21735
|
host: this.host,
|
|
21774
21736
|
state: "updated",
|
|
21775
|
-
...
|
|
21737
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21776
21738
|
version: bundledVersion,
|
|
21777
21739
|
scope: "user",
|
|
21778
21740
|
detail: `\u5DF2\u901A\u8FC7 codex plugin add \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
@@ -21783,41 +21745,63 @@ var codexUpgrader = {
|
|
|
21783
21745
|
|
|
21784
21746
|
// src/integrations/installation/upgraders/dsh.ts
|
|
21785
21747
|
var import_semver9 = __toESM(require_semver2(), 1);
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
const
|
|
21789
|
-
|
|
21790
|
-
|
|
21748
|
+
init_json();
|
|
21749
|
+
function parseInstalledVersion(raw) {
|
|
21750
|
+
const trimmed = raw.trim();
|
|
21751
|
+
if (!trimmed) return void 0;
|
|
21752
|
+
const parsed = JSON.parse(trimmed);
|
|
21753
|
+
const items = Array.isArray(parsed) ? parsed : [parsed];
|
|
21754
|
+
for (const item of items) {
|
|
21755
|
+
if (!object(item)) continue;
|
|
21756
|
+
const deps = item.dependencies;
|
|
21757
|
+
if (!object(deps)) continue;
|
|
21758
|
+
const pkg = deps["personal-bot"];
|
|
21759
|
+
if (object(pkg) && typeof pkg.version === "string" && (0, import_semver9.valid)(pkg.version)) return pkg.version;
|
|
21760
|
+
}
|
|
21761
|
+
return void 0;
|
|
21791
21762
|
}
|
|
21792
21763
|
var dshUpgrader = {
|
|
21793
21764
|
host: "dsh",
|
|
21794
21765
|
async upgrade(context) {
|
|
21795
|
-
|
|
21766
|
+
const profile = context.options.dshProfile || "pbot";
|
|
21767
|
+
const scope = `profile:${profile}`;
|
|
21768
|
+
const dsh = context.env.PBOT_DSH_COMMAND || await context.findExecutable("dsh");
|
|
21769
|
+
if (!dsh) {
|
|
21796
21770
|
return {
|
|
21797
21771
|
host: this.host,
|
|
21798
|
-
state: "
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21772
|
+
state: "skipped",
|
|
21773
|
+
scope,
|
|
21774
|
+
detail: "\u672A\u627E\u5230 dsh CLI\uFF08dsh\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21802
21775
|
};
|
|
21803
21776
|
}
|
|
21804
|
-
|
|
21805
|
-
|
|
21777
|
+
let installedVersion;
|
|
21778
|
+
try {
|
|
21779
|
+
const raw = await context.run(dsh, ["plugin", "--profile", profile, "list", "personal-bot", "--json"], context.workspace);
|
|
21780
|
+
installedVersion = parseInstalledVersion(raw);
|
|
21781
|
+
} catch (error) {
|
|
21806
21782
|
return {
|
|
21807
21783
|
host: this.host,
|
|
21808
|
-
state: "
|
|
21809
|
-
|
|
21810
|
-
detail:
|
|
21784
|
+
state: "failed",
|
|
21785
|
+
scope,
|
|
21786
|
+
detail: `\u67E5\u8BE2 dsh profile "${profile}" \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21811
21787
|
};
|
|
21812
21788
|
}
|
|
21813
|
-
|
|
21814
|
-
if (!dsh) {
|
|
21789
|
+
if (!installedVersion) {
|
|
21815
21790
|
return {
|
|
21816
21791
|
host: this.host,
|
|
21817
21792
|
state: "skipped",
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
|
|
21793
|
+
scope,
|
|
21794
|
+
detail: `dsh profile "${profile}" \u4E2D\u672A\u5B89\u88C5 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002`
|
|
21795
|
+
};
|
|
21796
|
+
}
|
|
21797
|
+
if ((0, import_semver9.gte)(installedVersion, context.targetVersion)) {
|
|
21798
|
+
return {
|
|
21799
|
+
host: this.host,
|
|
21800
|
+
state: "up-to-date",
|
|
21801
|
+
previousVersion: installedVersion,
|
|
21802
|
+
version: installedVersion,
|
|
21803
|
+
scope,
|
|
21804
|
+
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21821
21805
|
};
|
|
21822
21806
|
}
|
|
21823
21807
|
try {
|
|
@@ -21826,17 +21810,17 @@ var dshUpgrader = {
|
|
|
21826
21810
|
return {
|
|
21827
21811
|
host: this.host,
|
|
21828
21812
|
state: "failed",
|
|
21829
|
-
|
|
21830
|
-
scope
|
|
21813
|
+
previousVersion: installedVersion,
|
|
21814
|
+
scope,
|
|
21831
21815
|
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
21816
|
};
|
|
21833
21817
|
}
|
|
21834
21818
|
return {
|
|
21835
21819
|
host: this.host,
|
|
21836
21820
|
state: "updated",
|
|
21837
|
-
|
|
21821
|
+
previousVersion: installedVersion,
|
|
21838
21822
|
version: context.targetVersion,
|
|
21839
|
-
scope
|
|
21823
|
+
scope,
|
|
21840
21824
|
detail: `\u5DF2\u66F4\u65B0 dsh profile "${profile}" \u4E2D\u7684 personal-bot\u3002`,
|
|
21841
21825
|
nextStep: `\u91CD\u65B0\u542F\u52A8 dsh --profile ${profile} \u4F7F\u65B0\u7248\u672C\u751F\u6548\u3002`
|
|
21842
21826
|
};
|
|
@@ -21847,14 +21831,14 @@ var dshUpgrader = {
|
|
|
21847
21831
|
var import_semver10 = __toESM(require_semver2(), 1);
|
|
21848
21832
|
init_json();
|
|
21849
21833
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
21850
|
-
import { join as
|
|
21834
|
+
import { join as join26 } from "node:path";
|
|
21851
21835
|
function packageSource(entry) {
|
|
21852
21836
|
if (typeof entry === "string") return entry;
|
|
21853
21837
|
if (object(entry) && typeof entry.source === "string") return entry.source;
|
|
21854
21838
|
return void 0;
|
|
21855
21839
|
}
|
|
21856
21840
|
async function hasCustomOnlySource(workspace) {
|
|
21857
|
-
const settingsPath =
|
|
21841
|
+
const settingsPath = join26(workspace, ".pi", "settings.json");
|
|
21858
21842
|
try {
|
|
21859
21843
|
const data = JSON.parse(await readFile13(settingsPath, "utf8"));
|
|
21860
21844
|
if (!object(data) || !Array.isArray(data.packages)) return false;
|
|
@@ -21868,7 +21852,7 @@ async function hasCustomOnlySource(workspace) {
|
|
|
21868
21852
|
}
|
|
21869
21853
|
}
|
|
21870
21854
|
async function readLocalPiVersion(workspace) {
|
|
21871
|
-
const manifestPath =
|
|
21855
|
+
const manifestPath = join26(workspace, ".pi", "npm", "node_modules", "personal-bot", "package.json");
|
|
21872
21856
|
try {
|
|
21873
21857
|
const data = JSON.parse(await readFile13(manifestPath, "utf8"));
|
|
21874
21858
|
return object(data) && data.name === "personal-bot" && typeof data.version === "string" && (0, import_semver10.valid)(data.version) ? data.version : void 0;
|
|
@@ -21880,24 +21864,31 @@ async function readLocalPiVersion(workspace) {
|
|
|
21880
21864
|
var piUpgrader = {
|
|
21881
21865
|
host: "pi",
|
|
21882
21866
|
async upgrade(context) {
|
|
21883
|
-
|
|
21884
|
-
if (current && (0, import_semver10.valid)(current) && (0, import_semver10.gte)(current, context.targetVersion)) {
|
|
21867
|
+
if (await hasCustomOnlySource(context.workspace)) {
|
|
21885
21868
|
return {
|
|
21886
21869
|
host: this.host,
|
|
21887
|
-
state: "
|
|
21888
|
-
previousVersion: current,
|
|
21889
|
-
version: current,
|
|
21870
|
+
state: "skipped",
|
|
21890
21871
|
scope: "local",
|
|
21891
|
-
detail: "\u5DF2\
|
|
21872
|
+
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
21873
|
};
|
|
21893
21874
|
}
|
|
21894
|
-
|
|
21875
|
+
const current = await readLocalPiVersion(context.workspace);
|
|
21876
|
+
if (!current) {
|
|
21895
21877
|
return {
|
|
21896
21878
|
host: this.host,
|
|
21897
21879
|
state: "skipped",
|
|
21898
|
-
...current ? { previousVersion: current } : {},
|
|
21899
21880
|
scope: "local",
|
|
21900
|
-
detail: "\u5DE5\u4F5C\u533A Pi \
|
|
21881
|
+
detail: "\u5F53\u524D\u5DE5\u4F5C\u533A\u672A\u901A\u8FC7 Pi \u5B89\u88C5 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21882
|
+
};
|
|
21883
|
+
}
|
|
21884
|
+
if ((0, import_semver10.gte)(current, context.targetVersion)) {
|
|
21885
|
+
return {
|
|
21886
|
+
host: this.host,
|
|
21887
|
+
state: "up-to-date",
|
|
21888
|
+
previousVersion: current,
|
|
21889
|
+
version: current,
|
|
21890
|
+
scope: "local",
|
|
21891
|
+
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21901
21892
|
};
|
|
21902
21893
|
}
|
|
21903
21894
|
const pi = context.env.PBOT_PI_COMMAND || await context.findExecutable("pi");
|
|
@@ -21905,7 +21896,7 @@ var piUpgrader = {
|
|
|
21905
21896
|
return {
|
|
21906
21897
|
host: this.host,
|
|
21907
21898
|
state: "skipped",
|
|
21908
|
-
|
|
21899
|
+
previousVersion: current,
|
|
21909
21900
|
scope: "local",
|
|
21910
21901
|
detail: "\u672A\u627E\u5230 Pi CLI\uFF08pi\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21911
21902
|
};
|
|
@@ -21915,7 +21906,7 @@ var piUpgrader = {
|
|
|
21915
21906
|
return {
|
|
21916
21907
|
host: this.host,
|
|
21917
21908
|
state: "updated",
|
|
21918
|
-
|
|
21909
|
+
previousVersion: current,
|
|
21919
21910
|
version: installed,
|
|
21920
21911
|
scope: "local",
|
|
21921
21912
|
detail: `\u5DF2\u901A\u8FC7 pi install --local \u66F4\u65B0\u5DE5\u4F5C\u533A personal-bot \u5230 ${installed}\u3002`,
|
|
@@ -21927,8 +21918,8 @@ var piUpgrader = {
|
|
|
21927
21918
|
// src/integrations/installation/upgraders/qoder.ts
|
|
21928
21919
|
var import_semver11 = __toESM(require_semver2(), 1);
|
|
21929
21920
|
init_json();
|
|
21930
|
-
import { readFile as readFile14 } from "node:fs/promises";
|
|
21931
|
-
import { join as
|
|
21921
|
+
import { readFile as readFile14, realpath as realpath7 } from "node:fs/promises";
|
|
21922
|
+
import { join as join27 } from "node:path";
|
|
21932
21923
|
async function readManifestVersion6(path) {
|
|
21933
21924
|
try {
|
|
21934
21925
|
const data = JSON.parse(await readFile14(path, "utf8"));
|
|
@@ -21938,26 +21929,97 @@ async function readManifestVersion6(path) {
|
|
|
21938
21929
|
throw error;
|
|
21939
21930
|
}
|
|
21940
21931
|
}
|
|
21932
|
+
function parsePluginList4(raw) {
|
|
21933
|
+
const parsed = JSON.parse(raw);
|
|
21934
|
+
const items = Array.isArray(parsed) ? parsed : object(parsed) && Array.isArray(parsed.plugins) ? parsed.plugins : [];
|
|
21935
|
+
const entries = [];
|
|
21936
|
+
for (const item of items) {
|
|
21937
|
+
if (!object(item)) continue;
|
|
21938
|
+
const id = typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : void 0;
|
|
21939
|
+
if (!id) continue;
|
|
21940
|
+
entries.push({
|
|
21941
|
+
id,
|
|
21942
|
+
...typeof item.name === "string" ? { name: item.name } : {},
|
|
21943
|
+
...typeof item.version === "string" ? { version: item.version } : {},
|
|
21944
|
+
...typeof item.scope === "string" ? { scope: item.scope } : {},
|
|
21945
|
+
...typeof item.projectPath === "string" ? { projectPath: item.projectPath } : {}
|
|
21946
|
+
});
|
|
21947
|
+
}
|
|
21948
|
+
return entries;
|
|
21949
|
+
}
|
|
21950
|
+
async function resolvePathSafe2(value) {
|
|
21951
|
+
try {
|
|
21952
|
+
return await realpath7(value);
|
|
21953
|
+
} catch {
|
|
21954
|
+
return value;
|
|
21955
|
+
}
|
|
21956
|
+
}
|
|
21957
|
+
async function selectMatchingEntry2(entries, workspace) {
|
|
21958
|
+
const canonicalWorkspace = await resolvePathSafe2(workspace);
|
|
21959
|
+
const candidates = entries.filter((entry) => entry.name === "personal-bot" || entry.id === "personal-bot" || entry.id.startsWith("personal-bot@"));
|
|
21960
|
+
if (!candidates.length) return void 0;
|
|
21961
|
+
const scopedMatches = [];
|
|
21962
|
+
for (const entry of candidates) {
|
|
21963
|
+
if (!entry.projectPath) {
|
|
21964
|
+
scopedMatches.push(entry);
|
|
21965
|
+
continue;
|
|
21966
|
+
}
|
|
21967
|
+
if (await resolvePathSafe2(entry.projectPath) === canonicalWorkspace) scopedMatches.push(entry);
|
|
21968
|
+
}
|
|
21969
|
+
const priority = /* @__PURE__ */ new Map([["local", 0], ["project", 1], ["user", 2]]);
|
|
21970
|
+
scopedMatches.sort((a, b) => (priority.get(a.scope ?? "") ?? 9) - (priority.get(b.scope ?? "") ?? 9));
|
|
21971
|
+
return scopedMatches[0];
|
|
21972
|
+
}
|
|
21941
21973
|
var qoderUpgrader = {
|
|
21942
21974
|
host: "qoder",
|
|
21943
21975
|
async upgrade(context) {
|
|
21944
|
-
|
|
21976
|
+
const qodercli = context.env.PBOT_QODER_COMMAND || await context.findExecutable("qodercli");
|
|
21977
|
+
if (!qodercli) {
|
|
21978
|
+
return {
|
|
21979
|
+
host: this.host,
|
|
21980
|
+
state: "skipped",
|
|
21981
|
+
detail: "\u672A\u627E\u5230 Qoder CLI\uFF08qodercli\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
21982
|
+
};
|
|
21983
|
+
}
|
|
21984
|
+
let entries;
|
|
21985
|
+
try {
|
|
21986
|
+
const raw = await context.run(qodercli, ["plugin", "list", "--json"], context.workspace);
|
|
21987
|
+
entries = parsePluginList4(raw);
|
|
21988
|
+
} catch (error) {
|
|
21989
|
+
return {
|
|
21990
|
+
host: this.host,
|
|
21991
|
+
state: "failed",
|
|
21992
|
+
detail: `\u67E5\u8BE2 Qoder CLI \u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
21993
|
+
};
|
|
21994
|
+
}
|
|
21995
|
+
const entry = await selectMatchingEntry2(entries, context.workspace);
|
|
21996
|
+
if (!entry) {
|
|
21997
|
+
return {
|
|
21998
|
+
host: this.host,
|
|
21999
|
+
state: "skipped",
|
|
22000
|
+
detail: "\u672A\u5728 Qoder CLI \u63D2\u4EF6\u5217\u8868\u4E2D\u627E\u5230 personal-bot\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
22001
|
+
};
|
|
22002
|
+
}
|
|
22003
|
+
const installedVersion = entry.version;
|
|
22004
|
+
const scope = entry.scope ?? "user";
|
|
22005
|
+
if (installedVersion && (0, import_semver11.valid)(installedVersion) && (0, import_semver11.gte)(installedVersion, context.targetVersion)) {
|
|
21945
22006
|
return {
|
|
21946
22007
|
host: this.host,
|
|
21947
22008
|
state: "up-to-date",
|
|
21948
|
-
previousVersion:
|
|
21949
|
-
version:
|
|
21950
|
-
scope
|
|
22009
|
+
previousVersion: installedVersion,
|
|
22010
|
+
version: installedVersion,
|
|
22011
|
+
scope,
|
|
21951
22012
|
detail: "\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002"
|
|
21952
22013
|
};
|
|
21953
22014
|
}
|
|
21954
|
-
const pluginDir =
|
|
21955
|
-
const bundledVersion = await readManifestVersion6(
|
|
22015
|
+
const pluginDir = join27(context.packageRoot, "lib", "qoder-plugin");
|
|
22016
|
+
const bundledVersion = await readManifestVersion6(join27(pluginDir, ".qoder-plugin", "plugin.json"));
|
|
21956
22017
|
if (!bundledVersion) {
|
|
21957
22018
|
return {
|
|
21958
22019
|
host: this.host,
|
|
21959
22020
|
state: "skipped",
|
|
21960
|
-
...
|
|
22021
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
22022
|
+
scope,
|
|
21961
22023
|
detail: `\u7F3A\u5C11 Qoder CLI \u63D2\u4EF6\u6784\u5EFA\u4EA7\u7269\uFF1A${pluginDir}`
|
|
21962
22024
|
};
|
|
21963
22025
|
}
|
|
@@ -21965,27 +22027,19 @@ var qoderUpgrader = {
|
|
|
21965
22027
|
return {
|
|
21966
22028
|
host: this.host,
|
|
21967
22029
|
state: "skipped",
|
|
21968
|
-
...
|
|
22030
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
22031
|
+
scope,
|
|
21969
22032
|
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
22033
|
};
|
|
21971
22034
|
}
|
|
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);
|
|
22035
|
+
await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", scope], context.workspace);
|
|
21982
22036
|
return {
|
|
21983
22037
|
host: this.host,
|
|
21984
22038
|
state: "updated",
|
|
21985
|
-
...
|
|
22039
|
+
...installedVersion ? { previousVersion: installedVersion } : {},
|
|
21986
22040
|
version: bundledVersion,
|
|
21987
|
-
scope
|
|
21988
|
-
detail: `\u5DF2\u901A\u8FC7 qodercli plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
22041
|
+
scope,
|
|
22042
|
+
detail: `\u5DF2\u6309\u539F\u6709\u4F5C\u7528\u57DF\uFF08${scope}\uFF09\u901A\u8FC7 qodercli plugin install \u66F4\u65B0\u5230 ${bundledVersion}\u3002`,
|
|
21989
22043
|
nextStep: "\u91CD\u542F Qoder CLI \u4F1A\u8BDD\u4F7F\u65B0\u7248\u672C\u751F\u6548\u3002"
|
|
21990
22044
|
};
|
|
21991
22045
|
}
|
|
@@ -22021,11 +22075,12 @@ var hostUpgraders = new HostUpgraderRegistry([
|
|
|
22021
22075
|
dshUpgrader
|
|
22022
22076
|
]);
|
|
22023
22077
|
var getHostUpgrader = (host) => hostUpgraders.get(host);
|
|
22078
|
+
var listHostUpgraders = () => hostUpgraders.list();
|
|
22024
22079
|
|
|
22025
22080
|
// src/services/installation/upgrade-service.ts
|
|
22026
22081
|
var import_semver12 = __toESM(require_semver2(), 1);
|
|
22027
22082
|
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\
|
|
22083
|
+
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
22084
|
function parseUpgradeArgs(args) {
|
|
22030
22085
|
let workspace;
|
|
22031
22086
|
let version;
|
|
@@ -22090,7 +22145,6 @@ async function executeWorkspaceUpgrade(input) {
|
|
|
22090
22145
|
result = {
|
|
22091
22146
|
host: target.host,
|
|
22092
22147
|
state: "skipped",
|
|
22093
|
-
...target.currentVersion ? { previousVersion: target.currentVersion } : {},
|
|
22094
22148
|
detail: "\u672A\u6CE8\u518C\u8BE5\u5BBF\u4E3B\u7684\u81EA\u52A8\u5347\u7EA7\u9002\u914D\u5668\uFF0C\u5DF2\u8DF3\u8FC7\u3002"
|
|
22095
22149
|
};
|
|
22096
22150
|
} else {
|
|
@@ -22101,7 +22155,6 @@ async function executeWorkspaceUpgrade(input) {
|
|
|
22101
22155
|
result = {
|
|
22102
22156
|
host: target.host,
|
|
22103
22157
|
state: "failed",
|
|
22104
|
-
...target.currentVersion ? { previousVersion: target.currentVersion } : {},
|
|
22105
22158
|
detail: error instanceof Error ? error.message : String(error)
|
|
22106
22159
|
};
|
|
22107
22160
|
}
|
|
@@ -22136,31 +22189,9 @@ async function latestStableVersion(processes, cwd) {
|
|
|
22136
22189
|
if (typeof value.version !== "string") throw new Error("\u65E0\u6CD5\u53D6\u5F97 personal-bot \u7684\u6700\u65B0\u7248\u672C\u3002");
|
|
22137
22190
|
return checkStableVersion(value.version, value.engines?.node);
|
|
22138
22191
|
}
|
|
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));
|
|
22192
|
+
function resolveUpgradeTargets(requestedHosts) {
|
|
22193
|
+
const hosts = requestedHosts ?? listHostUpgraders();
|
|
22194
|
+
return hosts.map((host) => ({ host }));
|
|
22164
22195
|
}
|
|
22165
22196
|
function formatLine2(result) {
|
|
22166
22197
|
const transition = result.previousVersion && result.version && result.previousVersion !== result.version ? `${result.previousVersion} \u2192 ${result.version}` : result.version ?? result.previousVersion ?? "";
|
|
@@ -22174,7 +22205,7 @@ function printHumanSummary2(summary) {
|
|
|
22174
22205
|
console.log(`\u76EE\u6807\u7248\u672C\uFF1A${summary.targetVersion}`);
|
|
22175
22206
|
console.log(`[${summary.cli.state}] cli ${summary.cli.previousVersion} \u2192 ${summary.cli.version}: ${summary.cli.detail}`);
|
|
22176
22207
|
if (!summary.results.length) {
|
|
22177
|
-
console.log("\
|
|
22208
|
+
console.log("\u672A\u6CE8\u518C\u4EFB\u4F55\u5BBF\u4E3B\u5347\u7EA7\u9002\u914D\u5668\u3002");
|
|
22178
22209
|
return;
|
|
22179
22210
|
}
|
|
22180
22211
|
for (const result of summary.results) console.log(formatLine2(result));
|
|
@@ -22182,7 +22213,7 @@ function printHumanSummary2(summary) {
|
|
|
22182
22213
|
var upgradeCommand = {
|
|
22183
22214
|
name: "upgrade",
|
|
22184
22215
|
aliases: ["update"],
|
|
22185
|
-
summary: "\u7EDF\u4E00\u5347\u7EA7\u5168\u5C40 CLI \u4E0E\u5F53\u524D\u5DE5\u4F5C\u533A\u5DF2\
|
|
22216
|
+
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
22217
|
usage: upgradeUsage,
|
|
22187
22218
|
updatePolicy: "none",
|
|
22188
22219
|
supportsWorkspaceFlag: true,
|
|
@@ -22217,7 +22248,7 @@ var upgradeCommand = {
|
|
|
22217
22248
|
PBOT_UPGRADING_CLI: targetVersion,
|
|
22218
22249
|
PBOT_UPGRADING_PREVIOUS_VERSION: packageVersion
|
|
22219
22250
|
};
|
|
22220
|
-
return execCliEntry(
|
|
22251
|
+
return execCliEntry(join28(cliResult.globalDirectory, "bin", "pbot.mjs"), ctx.rawArgs, nextEnv);
|
|
22221
22252
|
}
|
|
22222
22253
|
cli = {
|
|
22223
22254
|
state: cliResult.state,
|
|
@@ -22226,19 +22257,17 @@ var upgradeCommand = {
|
|
|
22226
22257
|
detail: cliResult.detail
|
|
22227
22258
|
};
|
|
22228
22259
|
}
|
|
22229
|
-
const targets =
|
|
22260
|
+
const targets = resolveUpgradeTargets(parsed.hosts);
|
|
22230
22261
|
const summary = await executeWorkspaceUpgrade({
|
|
22231
22262
|
workspaceRoot: workspace,
|
|
22232
22263
|
targetVersion,
|
|
22233
22264
|
cli,
|
|
22234
22265
|
targets,
|
|
22235
22266
|
resolveUpgrader: getHostUpgrader,
|
|
22236
|
-
createContext: (
|
|
22267
|
+
createContext: () => ({
|
|
22237
22268
|
workspace,
|
|
22238
22269
|
targetVersion,
|
|
22239
|
-
...target.currentVersion ? { currentVersion: target.currentVersion } : {},
|
|
22240
22270
|
packageRoot,
|
|
22241
|
-
...target.bindingPath ? { bindingPath: target.bindingPath } : {},
|
|
22242
22271
|
env: process.env,
|
|
22243
22272
|
signal: controller.signal,
|
|
22244
22273
|
options: { dshProfile: parsed.dshProfile },
|
|
@@ -22262,18 +22291,14 @@ init_validation();
|
|
|
22262
22291
|
import { mkdir as mkdir5, stat as stat6 } from "node:fs/promises";
|
|
22263
22292
|
init_workspace_config2();
|
|
22264
22293
|
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\
|
|
22294
|
+
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
22295
|
async function reportWorkspaceStatus(root, compact, checkRelease) {
|
|
22267
22296
|
const configuration = await readWorkspaceConfig(root);
|
|
22268
22297
|
const active = checkRelease || configuration.enabled;
|
|
22269
|
-
const
|
|
22270
|
-
const required = active ? await minimumCliRelease(root, plugins) : void 0;
|
|
22271
|
-
const drift = workspacePluginDrift(plugins);
|
|
22298
|
+
const required = active ? await minimumCliRelease(root) : void 0;
|
|
22272
22299
|
printJson({
|
|
22273
22300
|
workspaceRoot: root,
|
|
22274
22301
|
version: packageVersion,
|
|
22275
|
-
plugins,
|
|
22276
|
-
outOfSync: drift.outOfSync,
|
|
22277
22302
|
minimumCliVersion: required ?? null,
|
|
22278
22303
|
configuration
|
|
22279
22304
|
}, compact);
|
|
@@ -22304,7 +22329,7 @@ var initCommand = {
|
|
|
22304
22329
|
};
|
|
22305
22330
|
var statusCommand = {
|
|
22306
22331
|
name: "status",
|
|
22307
|
-
summary: "\u67E5\u770B\u5DE5\u4F5C\u533A\u72B6\u6001\
|
|
22332
|
+
summary: "\u67E5\u770B\u5DE5\u4F5C\u533A\u72B6\u6001\u3001CLI \u7248\u672C\u4E0E\u914D\u7F6E",
|
|
22308
22333
|
usage: statusUsage,
|
|
22309
22334
|
updatePolicy: "workspace",
|
|
22310
22335
|
supportsWorkspaceFlag: true,
|
|
@@ -22365,7 +22390,7 @@ function formatRootHelp() {
|
|
|
22365
22390
|
return lines.join("\n");
|
|
22366
22391
|
}
|
|
22367
22392
|
async function updateForWorkspace(root, args, input) {
|
|
22368
|
-
return runUpdatedCli(await minimumCliRelease(root
|
|
22393
|
+
return runUpdatedCli(await minimumCliRelease(root), args, input);
|
|
22369
22394
|
}
|
|
22370
22395
|
async function updateForCommand(args) {
|
|
22371
22396
|
if (!args.length) return void 0;
|
|
@@ -22396,10 +22421,10 @@ async function main(args) {
|
|
|
22396
22421
|
try {
|
|
22397
22422
|
if (args[0] === "--at-least") {
|
|
22398
22423
|
const version = args[1];
|
|
22399
|
-
if (args.length !== 2 || !version || !(0,
|
|
22424
|
+
if (args.length !== 2 || !version || !(0, import_semver13.valid)(version)) {
|
|
22400
22425
|
throw new CliError("\u7528\u6CD5\uFF1Apbot --at-least <MAJOR.MINOR.PATCH>", 1);
|
|
22401
22426
|
}
|
|
22402
|
-
return (0,
|
|
22427
|
+
return (0, import_semver13.gte)(packageVersion, version) ? 0 : 1;
|
|
22403
22428
|
}
|
|
22404
22429
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
|
|
22405
22430
|
console.log(packageVersion);
|