vc-extras 0.0.0-stage → 0.1.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/README.md +70 -2
- package/agents/tester.md +23 -0
- package/install-extras.mjs +134 -0
- package/install-menu.mjs +63 -0
- package/install-skills.mjs +112 -0
- package/package.json +26 -4
- package/plugins/config-ui/index.ts +160 -0
- package/plugins/config-ui/lib/arguments.mjs +24 -0
- package/plugins/config-ui/lib/documents.mjs +67 -0
- package/plugins/config-ui/lib/frontmatter.mjs +91 -0
- package/plugins/config-ui/lib/open.mjs +17 -0
- package/plugins/config-ui/lib/ownership.mjs +99 -0
- package/plugins/config-ui/lib/page.mjs +11 -0
- package/plugins/config-ui/lib/patch.mjs +36 -0
- package/plugins/config-ui/lib/paths.mjs +14 -0
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -0
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -0
- package/plugins/config-ui/lib/redaction.mjs +8 -0
- package/plugins/config-ui/lib/registry.mjs +282 -0
- package/plugins/config-ui/lib/secrets.mjs +45 -0
- package/plugins/config-ui/lib/server.mjs +251 -0
- package/plugins/config-ui/lib/sources.mjs +96 -0
- package/plugins/config-ui/lib/state.mjs +157 -0
- package/plugins/config-ui/lib/themes.mjs +113 -0
- package/plugins/config-ui/lib/writer.mjs +691 -0
- package/plugins/config-ui/package.json +12 -0
- package/plugins/config-ui/project-local-owner.ts +106 -0
- package/plugins/config-ui/web/app.mjs +997 -0
- package/plugins/config-ui/web/index.html +342 -0
- package/plugins/essrj/context.ts +47 -0
- package/plugins/essrj/data.ts +190 -0
- package/plugins/essrj/index.ts +139 -0
- package/plugins/essrj/package.json +12 -0
- package/plugins/essrj/project-local-owner.ts +106 -0
- package/plugins/essrj/render.ts +217 -0
- package/plugins/essrj/types.ts +40 -0
- package/plugins.json +38 -0
- package/skills/animate/LICENSE +21 -0
- package/skills/animate/RECIPES.md +324 -0
- package/skills/animate/SKILL.md +208 -0
- package/skills/animate/UPSTREAM.md +19 -0
- package/skills/animation-performance/LICENSE +21 -0
- package/skills/animation-performance/SKILL.md +223 -0
- package/skills/animation-performance/UPSTREAM.md +19 -0
- package/skills/answer-me-with-html/SKILL.md +174 -0
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -0
- package/skills/apple-design/LICENSE +21 -0
- package/skills/apple-design/SKILL.md +291 -0
- package/skills/apple-design/UPSTREAM.md +19 -0
- package/skills/bad-smell/SKILL.md +44 -0
- package/skills/commit/SKILL.md +90 -0
- package/skills/emil-design-eng/LICENSE +21 -0
- package/skills/emil-design-eng/SKILL.md +677 -0
- package/skills/emil-design-eng/UPSTREAM.md +19 -0
- package/skills/find-the-truth/SKILL.md +38 -0
- package/skills/find-the-truth/references/trace-method.md +48 -0
- package/skills/find-the-truth/references/truth-method.md +39 -0
- package/skills/gestures/LICENSE +21 -0
- package/skills/gestures/SKILL.md +107 -0
- package/skills/gestures/UPSTREAM.md +19 -0
- package/skills/humanizer-zh/LICENSE +21 -0
- package/skills/humanizer-zh/SKILL.md +409 -0
- package/skills/humanizer-zh/UPSTREAM.md +7 -0
- package/skills/impeccable/LICENSE +191 -0
- package/skills/impeccable/NOTICE.md +11 -0
- package/skills/impeccable/SKILL.md +90 -0
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +9 -0
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -0
- package/skills/impeccable/reference/adapt.md +318 -0
- package/skills/impeccable/reference/adapt.native.md +58 -0
- package/skills/impeccable/reference/android.md +46 -0
- package/skills/impeccable/reference/animate.md +89 -0
- package/skills/impeccable/reference/audit.md +139 -0
- package/skills/impeccable/reference/audit.native.md +139 -0
- package/skills/impeccable/reference/bolder.md +33 -0
- package/skills/impeccable/reference/clarify.md +94 -0
- package/skills/impeccable/reference/colorize.md +86 -0
- package/skills/impeccable/reference/component-review.md +63 -0
- package/skills/impeccable/reference/craft-floor.md +44 -0
- package/skills/impeccable/reference/craft.md +5 -0
- package/skills/impeccable/reference/critique.md +819 -0
- package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/skills/impeccable/reference/delight.md +70 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/doctor.md +54 -0
- package/skills/impeccable/reference/document.md +416 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/generate.md +101 -0
- package/skills/impeccable/reference/harden.md +362 -0
- package/skills/impeccable/reference/hooks.md +114 -0
- package/skills/impeccable/reference/init.md +131 -0
- package/skills/impeccable/reference/ios.md +51 -0
- package/skills/impeccable/reference/layout.md +84 -0
- package/skills/impeccable/reference/live-setup.md +104 -0
- package/skills/impeccable/reference/live.md +327 -0
- package/skills/impeccable/reference/mode-operate.md +21 -0
- package/skills/impeccable/reference/mode-persuade.md +19 -0
- package/skills/impeccable/reference/mode-read.md +21 -0
- package/skills/impeccable/reference/new-work.md +152 -0
- package/skills/impeccable/reference/onboard.md +234 -0
- package/skills/impeccable/reference/operate.md +61 -0
- package/skills/impeccable/reference/optimize.md +257 -0
- package/skills/impeccable/reference/overdrive.md +127 -0
- package/skills/impeccable/reference/polish.md +105 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/region-map.md +26 -0
- package/skills/impeccable/reference/routing.md +24 -0
- package/skills/impeccable/reference/shape.md +59 -0
- package/skills/impeccable/reference/typeset.md +90 -0
- package/skills/impeccable/reference/visualize.md +47 -0
- package/skills/impeccable/scripts/VERSION +1 -0
- package/skills/impeccable/scripts/command-metadata.json +98 -0
- package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/impeccable/scripts/data/font-index.json +1 -0
- package/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/skills/impeccable/scripts/impeccable +249 -0
- package/skills/impeccable/scripts/impeccable.cmd +278 -0
- package/skills/impeccable/scripts/live-browser-dom.js +320 -0
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
- package/skills/impeccable/scripts/live-browser-session.js +183 -0
- package/skills/impeccable/scripts/live-browser.js +13862 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/improve-animations/AUDIT.md +115 -0
- package/skills/improve-animations/LICENSE +21 -0
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -0
- package/skills/improve-animations/SKILL.md +110 -0
- package/skills/improve-animations/UPSTREAM.md +19 -0
- package/skills/pick-ui-library/LICENSE +21 -0
- package/skills/pick-ui-library/SKILL.md +85 -0
- package/skills/pick-ui-library/UPSTREAM.md +19 -0
- package/skills/review-animations/LICENSE +21 -0
- package/skills/review-animations/SKILL.md +120 -0
- package/skills/review-animations/STANDARDS.md +187 -0
- package/skills/review-animations/UPSTREAM.md +19 -0
- package/skills/test/SKILL.md +29 -0
- package/skills/test/references/test-method.md +60 -0
- package/skills/write-doc/SKILL.md +115 -0
- package/skills/write-doc/examples/result-report.md +53 -0
- package/skills/write-doc/examples/task-summary.md +45 -0
- package/skills/write-doc/references/terminology.md +147 -0
- package/specs/design-demo.md +1102 -0
- package/specs/frontend-immersive.md +28 -0
- package/specs/web-modes/explore.md +31 -0
- package/specs/web-modes/risk.md +15 -0
- package/specs/web-modes/verify.md +16 -0
- package/vc-extras.mjs +78 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import * as toml from "smol-toml";
|
|
4
|
+
import { parse, modify, applyEdits } from "jsonc-parser";
|
|
5
|
+
|
|
6
|
+
export function parseDocument(raw, kind) {
|
|
7
|
+
try {
|
|
8
|
+
const clean = raw.replace(/^\uFEFF/, "");
|
|
9
|
+
let value;
|
|
10
|
+
if (kind === "toml") value = toml.parse(clean, { integersAsBigInt: true, unsafeKeyBehaviour: "throw" });
|
|
11
|
+
else if (kind === "jsonc") {
|
|
12
|
+
const errors = [];
|
|
13
|
+
value = parse(clean, errors, { allowTrailingComma: true });
|
|
14
|
+
if (errors.length) throw new Error("invalid JSONC");
|
|
15
|
+
} else value = JSON.parse(clean);
|
|
16
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("expected object");
|
|
17
|
+
return value;
|
|
18
|
+
} catch { throw new Error("配置语法或根对象不正确,请先修正文件;原文件未改动。"); }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function readDocument(file, kind) {
|
|
22
|
+
const raw = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : "";
|
|
23
|
+
return { raw, value: raw || fs.existsSync(file) ? parseDocument(raw, kind) : {} };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function encodeDocument(raw, before, after, kind) {
|
|
27
|
+
if (kind === "toml") {
|
|
28
|
+
const encoded = toml.stringify(after, { numbersAsFloat: true });
|
|
29
|
+
if (!sameToml(toml.parse(encoded, { integersAsBigInt: true, unsafeKeyBehaviour: "throw" }), after))
|
|
30
|
+
throw new Error("TOML 值或类型无法无损保留,拒绝写入。");
|
|
31
|
+
return encoded;
|
|
32
|
+
}
|
|
33
|
+
if (kind === "jsonc") {
|
|
34
|
+
let next = raw || "{}";
|
|
35
|
+
const visit = (left, right, keys = []) => {
|
|
36
|
+
const record = v => v && typeof v === "object" && !Array.isArray(v);
|
|
37
|
+
if (record(left) && record(right)) {
|
|
38
|
+
for (const key of new Set([...Object.keys(left), ...Object.keys(right)])) visit(left[key], right[key], [...keys, key]);
|
|
39
|
+
} else if (!isDeepStrictEqual(left, right)) {
|
|
40
|
+
next = applyEdits(next, modify(next, keys, right, { formattingOptions: { insertSpaces: true, tabSize: 2 } }));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
visit(before, after);
|
|
44
|
+
return next.endsWith("\n") ? next : next + "\n";
|
|
45
|
+
}
|
|
46
|
+
return JSON.stringify(after, null, 2) + "\n";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function sameToml(left, right) {
|
|
50
|
+
if (Object.is(left, right)) return true;
|
|
51
|
+
if (left instanceof Date || right instanceof Date) return isDeepStrictEqual(left, right);
|
|
52
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object" || Array.isArray(left) !== Array.isArray(right)) return false;
|
|
53
|
+
const keys = Object.keys(left);
|
|
54
|
+
return keys.length === Object.keys(right).length && keys.every(key => Object.hasOwn(right, key) && sameToml(left[key], right[key]));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function cloneDocument(value) {
|
|
58
|
+
if (Array.isArray(value)) return value.map(cloneDocument);
|
|
59
|
+
if (value instanceof Date) return value;
|
|
60
|
+
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneDocument(item)]));
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function pageValue(value) {
|
|
65
|
+
if (typeof value === "bigint") return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : null;
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The two project files the agent page edits are Markdown documents with a YAML
|
|
2
|
+
// frontmatter block: `.pi/agents/<role>.md` overrides and `.agents/agents/reviewer.md`.
|
|
3
|
+
// Only a handful of top-level keys belong to the page, and everything else — the prompt
|
|
4
|
+
// body, comments, key order, blank lines, the original line endings — must survive a save
|
|
5
|
+
// byte-for-byte. A YAML round-trip would not promise that, so the block is edited as text.
|
|
6
|
+
const OPEN = /^(?:\uFEFF)?---[ \t]*\r?\n/;
|
|
7
|
+
|
|
8
|
+
export function splitFrontmatter(raw) {
|
|
9
|
+
const text = String(raw ?? "");
|
|
10
|
+
const open = OPEN.exec(text);
|
|
11
|
+
if (!open) return null;
|
|
12
|
+
const rest = text.slice(open[0].length);
|
|
13
|
+
const close = /^---[ \t]*(?:\r?\n|$)/m.exec(rest);
|
|
14
|
+
if (!close) return null;
|
|
15
|
+
return {
|
|
16
|
+
head: text.slice(0, open[0].length),
|
|
17
|
+
body: rest.slice(0, close.index),
|
|
18
|
+
tail: rest.slice(close.index),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Scalar-only, one line per key: enough for `model` and `thinking`, and deliberately
|
|
23
|
+
// blind to nested blocks (they are other keys' business and stay untouched).
|
|
24
|
+
export function parseFrontmatter(raw) {
|
|
25
|
+
const parts = splitFrontmatter(raw);
|
|
26
|
+
if (!parts) return {};
|
|
27
|
+
const values = {};
|
|
28
|
+
for (const line of parts.body.split(/\r?\n/)) {
|
|
29
|
+
const match = /^([A-Za-z0-9_-]+):[ \t]*(.*)$/.exec(line);
|
|
30
|
+
if (match) values[match[1]] = parseScalar(match[2]);
|
|
31
|
+
}
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseScalar(raw) {
|
|
36
|
+
const value = raw.trim();
|
|
37
|
+
if (value === "" || value === "~" || value === "null") return null;
|
|
38
|
+
if (value === "true") return true;
|
|
39
|
+
if (value === "false") return false;
|
|
40
|
+
if (/^-?\d+(?:\.\d+)?$/.test(value)) return Number(value);
|
|
41
|
+
if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'")))
|
|
42
|
+
return value.slice(1, -1);
|
|
43
|
+
if (value.startsWith("[") && value.endsWith("]"))
|
|
44
|
+
return value.slice(1, -1).split(",").map((item) => parseScalar(item)).filter((item) => item !== null);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function formatScalar(value) {
|
|
49
|
+
if (typeof value === "boolean" || typeof value === "number") return String(value);
|
|
50
|
+
const text = String(value);
|
|
51
|
+
return /[:#\[\]{}",]|^[\s]|[\s]$|^(true|false|null|~|-?\d+(\.\d+)?)$/.test(text) ? JSON.stringify(text) : text;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// `changes` maps a top-level key to its new value; `null` removes the key. Returns the
|
|
55
|
+
// document unchanged when there is nothing to do.
|
|
56
|
+
export function applyFrontmatterKeys(raw, changes) {
|
|
57
|
+
const text = String(raw ?? "");
|
|
58
|
+
const newline = text.includes("\r\n") ? "\r\n" : "\n";
|
|
59
|
+
const parts = splitFrontmatter(text);
|
|
60
|
+
const pending = Object.entries(changes);
|
|
61
|
+
|
|
62
|
+
if (!parts) {
|
|
63
|
+
if (!pending.length) return text;
|
|
64
|
+
const block = pending.map(([key, value]) => `${key}: ${formatScalar(value)}`).join(newline);
|
|
65
|
+
return `---${newline}${block}${newline}---${newline}${text}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const lines = parts.body.split(/\r?\n/);
|
|
69
|
+
const remaining = new Map(pending);
|
|
70
|
+
const kept = [];
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
const match = /^([A-Za-z0-9_-]+):/.exec(line);
|
|
73
|
+
if (!match || !remaining.has(match[1])) {
|
|
74
|
+
kept.push(line);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const value = remaining.get(match[1]);
|
|
78
|
+
remaining.delete(match[1]);
|
|
79
|
+
if (value !== null) kept.push(`${match[1]}: ${formatScalar(value)}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// New keys go after the last existing key so the file still reads like a header.
|
|
83
|
+
for (const [key, value] of remaining) {
|
|
84
|
+
if (value === null) continue;
|
|
85
|
+
let insert = kept.length;
|
|
86
|
+
while (insert > 0 && kept[insert - 1].trim() === "") insert -= 1;
|
|
87
|
+
kept.splice(insert, 0, `${key}: ${formatScalar(value)}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return `${parts.head}${kept.join(newline)}${parts.tail}`;
|
|
91
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Opening the page in the user's browser, without pulling in a dependency: each
|
|
2
|
+
// platform has one command for it. A failure to open is not fatal — the caller
|
|
3
|
+
// still prints the URL.
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
export function openBrowser(url) {
|
|
7
|
+
const [command, args] = process.platform === "win32"
|
|
8
|
+
? ["cmd", ["/c", "start", "", url]]
|
|
9
|
+
: process.platform === "darwin"
|
|
10
|
+
? ["open", [url]]
|
|
11
|
+
: ["xdg-open", [url]];
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
14
|
+
child.once("error", () => resolve(false));
|
|
15
|
+
child.once("spawn", () => { child.unref(); resolve(true); });
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Registering a project-level file that `/config` wrote, so Emma can roll it back.
|
|
2
|
+
//
|
|
3
|
+
// The published extension lives at `<project>/.emma/runtime/config-ui/lib/`, while the
|
|
4
|
+
// installer's `src/installer/project-install.js` is not part of that published tree —
|
|
5
|
+
// importing it would break the runtime. The state contract is therefore reproduced here,
|
|
6
|
+
// and `test/pi-core/config-ownership.test.mjs` pins this module against the installer's
|
|
7
|
+
// own `ownedFileEntry` so the two cannot drift.
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
|
|
12
|
+
export const PROJECT_INSTALL_STATE = "project-install.json";
|
|
13
|
+
const STATE_KIND = "vibe-emma-project-install";
|
|
14
|
+
|
|
15
|
+
// The installer owns this set (src/installer/project-install.js `ownedProjectPath`).
|
|
16
|
+
// A path outside it must never be registered: the state file's validator rejects it.
|
|
17
|
+
const RETIRED_RENDERER_CONFIG = ".pi/compact-tools.json";
|
|
18
|
+
const OWNED_PATTERNS = [
|
|
19
|
+
/^\.pi\/agents\/[^/]+\.md$/,
|
|
20
|
+
/^\.agents\/agents\/[^/]+\.md$/,
|
|
21
|
+
/^\.emma\/agents\/[^/]+\.md$/,
|
|
22
|
+
/^\.emma\/agents\/web-modes\/[^/]+\.md$/,
|
|
23
|
+
/^\.pi\/extensions\/pi-permission-system\/config\.json$/,
|
|
24
|
+
/^\.pi\/automode\.json$/,
|
|
25
|
+
/^\.pi\/automode\.local\.json$/,
|
|
26
|
+
/^\.pi\/subagents\.json$/,
|
|
27
|
+
/^\.cortexkit\/magic-context\.jsonc$/,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const statePath = (projectRoot) => path.join(path.resolve(projectRoot), ".emma", PROJECT_INSTALL_STATE);
|
|
31
|
+
|
|
32
|
+
export function isOwnedProjectPath(relative) {
|
|
33
|
+
const normalized = String(relative).replace(/\\/g, "/").replace(/^\.\//, "");
|
|
34
|
+
return OWNED_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function fileFingerprint(file) {
|
|
38
|
+
return `sha256:${createHash("sha256").update(fs.readFileSync(file)).digest("hex")}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The entry shape the installer writes for a project-owned file.
|
|
42
|
+
export function ownedEntry(projectRoot, file) {
|
|
43
|
+
const root = path.resolve(projectRoot);
|
|
44
|
+
const absolute = path.resolve(file);
|
|
45
|
+
const relative = path.relative(root, absolute).replace(/\\/g, "/");
|
|
46
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative) || !isOwnedProjectPath(relative))
|
|
47
|
+
throw new Error(`Emma project-owned file is outside the managed path set: ${absolute}`);
|
|
48
|
+
if (!fs.existsSync(absolute) || !fs.lstatSync(absolute).isFile())
|
|
49
|
+
throw new Error(`Emma project-owned file is missing or not regular: ${absolute}`);
|
|
50
|
+
return { path: relative, fingerprint: fileFingerprint(absolute) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function validState(value) {
|
|
54
|
+
return Boolean(
|
|
55
|
+
value && value.version === 1 && value.kind === STATE_KIND &&
|
|
56
|
+
typeof value.emmaVersion === "string" &&
|
|
57
|
+
Array.isArray(value.packages) && Array.isArray(value.files) &&
|
|
58
|
+
value.files.every((entry) =>
|
|
59
|
+
entry && typeof entry.path === "string" && typeof entry.fingerprint === "string" &&
|
|
60
|
+
(isOwnedProjectPath(entry.path) || entry.path === RETIRED_RENDERER_CONFIG)),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Registers the written project files in the project install state. A project without
|
|
65
|
+
// Emma's install state is left alone: there is nothing to roll back into, and inventing
|
|
66
|
+
// a state file would fabricate a version and an ownership claim. A state that fails its
|
|
67
|
+
// own contract is reported rather than rewritten.
|
|
68
|
+
export function registerOwnedFiles(projectRoot, files) {
|
|
69
|
+
const file = statePath(projectRoot);
|
|
70
|
+
if (!files.length || !fs.existsSync(file)) return { registered: [], reason: fs.existsSync(file) ? "no files" : "no state" };
|
|
71
|
+
|
|
72
|
+
let state;
|
|
73
|
+
try {
|
|
74
|
+
state = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return { registered: [], reason: `invalid state: ${error instanceof Error ? error.message : String(error)}` };
|
|
77
|
+
}
|
|
78
|
+
if (!validState(state)) return { registered: [], reason: "invalid state" };
|
|
79
|
+
|
|
80
|
+
const byPath = new Map(state.files.filter(entry => entry.path !== RETIRED_RENDERER_CONFIG).map((entry) => [entry.path, entry]));
|
|
81
|
+
for (const target of files) {
|
|
82
|
+
const entry = ownedEntry(projectRoot, target);
|
|
83
|
+
byPath.set(entry.path, entry);
|
|
84
|
+
}
|
|
85
|
+
const next = {
|
|
86
|
+
...state,
|
|
87
|
+
files: [...byPath.values()].sort((left, right) => left.path.localeCompare(right.path)),
|
|
88
|
+
};
|
|
89
|
+
if (JSON.stringify(next.files) === JSON.stringify(state.files)) return { registered: [], reason: "unchanged" };
|
|
90
|
+
|
|
91
|
+
const temporary = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
92
|
+
try {
|
|
93
|
+
fs.writeFileSync(temporary, `${JSON.stringify(next, null, 2)}\n`, { flag: "wx", mode: 0o600 });
|
|
94
|
+
fs.renameSync(temporary, file);
|
|
95
|
+
} finally {
|
|
96
|
+
fs.rmSync(temporary, { force: true });
|
|
97
|
+
}
|
|
98
|
+
return { registered: byPath.size ? files.map((target) => ownedEntry(projectRoot, target).path) : [] };
|
|
99
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The offline page has to be one file: a module loaded from `file://` is refused by
|
|
2
|
+
// the browser, so `app.mjs` is inlined into the HTML.
|
|
3
|
+
//
|
|
4
|
+
// `String.replace` treats `$$` in a string replacement as an escape, and app.mjs uses
|
|
5
|
+
// `$$` as its query helper — passing the code as a replacement string silently
|
|
6
|
+
// corrupts it. A replacer function returns the code verbatim.
|
|
7
|
+
export function inlinePage(html, appCode) {
|
|
8
|
+
const marker = '<script type="module" src="./app.mjs"></script>';
|
|
9
|
+
if (!html.includes(marker)) throw new Error("配置页缺少 app.mjs 的 script 标记,无法生成离线页面");
|
|
10
|
+
return html.replace(marker, () => `<script type="module">${appCode}</script>`);
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The no-server path: the page saves a patch file instead of calling the local
|
|
2
|
+
// service, and the terminal applies it later. A patch carries only field ids and
|
|
3
|
+
// values, so a hand-edited file cannot address a path the registry does not own —
|
|
4
|
+
// unknown ids are reported and dropped rather than written.
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import { fieldById } from "./registry.mjs";
|
|
7
|
+
import { applyChanges, planChanges } from "./writer.mjs";
|
|
8
|
+
|
|
9
|
+
export const PATCH_KIND = "vibe-emma-config-patch";
|
|
10
|
+
|
|
11
|
+
export function createPatch({ values, expectations, createdAt = new Date().toISOString() }) {
|
|
12
|
+
return { version: 2, kind: PATCH_KIND, createdAt, values, expectations };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function readPatch(file) {
|
|
16
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
|
|
17
|
+
if (parsed?.kind !== PATCH_KIND || parsed?.version !== 2 || !parsed.values || typeof parsed.values !== "object")
|
|
18
|
+
throw new Error(`不是 Emma 配置补丁:${file}`);
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function applyPatch({ patch, context, dryRun = false }) {
|
|
23
|
+
const values = {};
|
|
24
|
+
const unknown = [];
|
|
25
|
+
for (const [id, value] of Object.entries(patch.values)) {
|
|
26
|
+
if (fieldById(id)) values[id] = value;
|
|
27
|
+
else unknown.push(id);
|
|
28
|
+
}
|
|
29
|
+
const baseline = patch.expectations;
|
|
30
|
+
const missing = Object.keys(values).filter(id => !baseline?.[fieldById(id).file] || typeof baseline[fieldById(id).file].path !== "string");
|
|
31
|
+
const plan = missing.length
|
|
32
|
+
? { files: [], skipped: [], problems: [{ id: "patch", reason: "补丁缺少导出时的目标和文件基线,请重新导出。" }] }
|
|
33
|
+
: planChanges({ values, context, expectations: baseline });
|
|
34
|
+
const applied = applyChanges(plan, { context, dryRun });
|
|
35
|
+
return { plan, unknown, results: applied.results, skipped: plan.skipped, ownership: applied.ownership, failure: applied.failure };
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Path resolution shared by the config UI runtime and the installer. The agent
|
|
2
|
+
// directory is where Pi keeps every user-level config file, and it is relocatable
|
|
3
|
+
// through PI_CODING_AGENT_DIR, so nothing may hardcode `~/.pi/agent`.
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
|
|
7
|
+
export function resolveAgentDir(env = process.env, homeDir = os.homedir()) {
|
|
8
|
+
const home = path.resolve(homeDir);
|
|
9
|
+
const configured = env.PI_CODING_AGENT_DIR?.trim();
|
|
10
|
+
if (!configured) return path.join(home, ".pi", "agent");
|
|
11
|
+
if (configured === "~") return home;
|
|
12
|
+
if (configured.startsWith("~/")) return path.resolve(home, configured.slice(2));
|
|
13
|
+
return path.resolve(configured);
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const integer = (id, group, file, key, label, min, max, fallback) => ({ id, group, file, key, label, kind: "integer", min, max, default: fallback });
|
|
2
|
+
const bool = (id, group, file, key, label, fallback) => ({ id, group, file, key, label, kind: "boolean", default: fallback });
|
|
3
|
+
const text = (id, group, file, key, label, fallback) => ({ id, group, file, key, label, kind: "text", empty: "", default: fallback, maxLength: 4000 });
|
|
4
|
+
const choice = (id, group, file, key, label, values, fallback) => ({ id, group, file, key, label, kind: "enum", values, default: fallback });
|
|
5
|
+
const limit = Number.MAX_SAFE_INTEGER;
|
|
6
|
+
export const PLUGIN_FIELDS = [
|
|
7
|
+
{ ...choice("pccMode", "plugins", "piCcExtensions", "mode", "显示模式", ["on", "compact", "off"], "on"), section: "显示与预览", selectOptions: [{ value: "on", label: "开启(on)" }, { value: "compact", label: "紧凑(compact)" }, { value: "off", label: "关闭(off)" }] },
|
|
8
|
+
{ ...integer("pccPreviewLines", "plugins", "piCcExtensions", "previewLines", "思考预览行数", 0, limit, 3), help: "0 表示隐藏折叠状态下的思考预览。" },
|
|
9
|
+
{ id: "pccExclude", group: "plugins", file: "piCcExtensions", key: "excludeRenderers", label: "保留原生渲染", kind: "string-list", default: [], placeholder: "如 bash, read;留空表示不排除", help: "用逗号分隔工具名,这些工具继续使用 Pi 原生渲染。" },
|
|
10
|
+
integer("pccExpandedMax", "plugins", "piCcExtensions", "expandedPreviewMaxLines", "展开预览行数", 10, 50000, 40),
|
|
11
|
+
integer("pccInputMax", "plugins", "piCcExtensions", "expandedInputMaxLines", "展开输入行数", 1, 5000, 5),
|
|
12
|
+
integer("pccOutputMax", "plugins", "piCcExtensions", "expandedOutputMaxLines", "展开输出行数", 1, 5000, 10),
|
|
13
|
+
bool("pccSummaryTitle", "plugins", "piCcExtensions", "useSummaryTitlesAsThinkingTitle", "用摘要作为思考标题", true),
|
|
14
|
+
{ ...choice("pccDiffView", "plugins", "piCcExtensions", "diffViewMode", "Diff 布局", ["auto", "split", "unified"], "auto"), section: "Diff 显示", selectOptions: [{ value: "auto", label: "自动" }, { value: "split", label: "左右对比" }, { value: "unified", label: "统一视图" }] },
|
|
15
|
+
{ ...choice("pccDiffIndicator", "plugins", "piCcExtensions", "diffIndicatorMode", "Diff 指示器", ["bars", "classic", "none"], "bars"), selectOptions: [{ value: "bars", label: "色条" }, { value: "classic", label: "经典 + / −" }, { value: "none", label: "隐藏" }] },
|
|
16
|
+
{ ...integer("pccDiffWidth", "plugins", "piCcExtensions", "diffSplitMinWidth", "左右对比最小宽度", 40, 300, 120), help: "自动布局达到此终端列宽时,使用左右对比。" },
|
|
17
|
+
integer("pccEditLines", "plugins", "piCcExtensions", "editDiffCollapsedLines", "编辑 Diff 折叠行数", 0, 500, 24),
|
|
18
|
+
{ ...integer("pccWriteLines", "plugins", "piCcExtensions", "writeDiffCollapsedLines", "写入 Diff 折叠行数", 0, 500, 0), help: "0 表示仅显示变更统计。" },
|
|
19
|
+
bool("pccWordWrap", "plugins", "piCcExtensions", "diffWordWrap", "Diff 自动换行", true),
|
|
20
|
+
{ ...bool("pccSessionRef", "plugins", "piCcExtensions", "enableSessionReference", "启用 Session 引用", true), section: "交互增强" },
|
|
21
|
+
bool("pccSubagentAutocomplete", "plugins", "piCcExtensions", "enableSubagentAutocomplete", "子代理自动补全", true),
|
|
22
|
+
bool("pccContextCommand", "plugins", "piCcExtensions", "enableContextCommand", "启用 /context", true),
|
|
23
|
+
bool("pccAgentSummary", "plugins", "piCcExtensions", "enableAgentSummary", "显示代理摘要", true),
|
|
24
|
+
bool("pccWorkingMessage", "plugins", "piCcExtensions", "enableWorkingMessage", "显示工作提示", true),
|
|
25
|
+
bool("pccAliases", "plugins", "piCcExtensions", "enableAliases", "启用命令别名", true),
|
|
26
|
+
bool("pccMarkdown", "plugins", "piCcExtensions", "enableMarkdownEnhance", "Markdown 增强", true),
|
|
27
|
+
bool("pccStartupHeader", "plugins", "piCcExtensions", "showStartupHeader", "显示启动标题", true),
|
|
28
|
+
bool("pccStickyMessage", "plugins", "piCcExtensions", "stickyUserMessage", "固定当前用户消息", true),
|
|
29
|
+
{ ...choice("pccScrollButton", "plugins", "piCcExtensions", "scrollButtonMode", "回到底部按钮", ["dock", "native"], "dock"), selectOptions: [{ value: "dock", label: "扩展停靠栏" }, { value: "native", label: "Pi 原生按钮" }] },
|
|
30
|
+
{ ...bool("pccCustomFooter", "plugins", "piCcExtensions", "enableCustomFooter", "启用自定义状态栏", true), section: "状态栏" },
|
|
31
|
+
bool("pccTokenRate", "plugins", "piCcExtensions", "footerTokenRate", "显示输出速率", true),
|
|
32
|
+
{ ...choice("pccTokenRateMode", "plugins", "piCcExtensions", "footerTokenRateMode", "输出速率计算方式", ["average", "live"], "average"), selectOptions: [{ value: "average", label: "整段指令平均" }, { value: "live", label: "最近一秒实时" }] },
|
|
33
|
+
bool("pccTokenRateTtft", "plugins", "piCcExtensions", "footerTokenRateTtft", "显示首个 Token 等待时间", true),
|
|
34
|
+
bool("pccSessionTokens", "plugins", "piCcExtensions", "footerSessionTokens", "显示会话累计 Token", false),
|
|
35
|
+
bool("pccNerdIcons", "plugins", "piCcExtensions", "footerNerdIcons", "使用 Nerd Font 图标", true),
|
|
36
|
+
{ ...choice("pccGitStats", "plugins", "piCcExtensions", "footerGitStatsMode", "Git 统计范围", ["working", "branch"], "working"), selectOptions: [{ value: "working", label: "工作区" }, { value: "branch", label: "分支" }] },
|
|
37
|
+
choice("fffMode", "plugins", "piFff", "mode", "FFF 接管模式", ["tools-and-ui", "tools-only", "override"], "tools-and-ui"),
|
|
38
|
+
bool("fffRoot", "plugins", "piFff", "enableFsRootScanning", "允许根目录扫描", false),
|
|
39
|
+
text("fffFrecency", "plugins", "piFff", "frecencyDbPath", "频率数据库路径"),
|
|
40
|
+
text("fffHistory", "plugins", "piFff", "historyDbPath", "历史数据库路径"),
|
|
41
|
+
{ ...choice("btwThinking", "plugins", "piBtw", "thinkingLevel", "侧模型思考级别", ["inherit", "off", "minimal", "low", "medium", "high", "xhigh", "max"], "inherit"), empty: "inherit" },
|
|
42
|
+
bool("btwRemember", "plugins", "piBtw", "rememberThinkingLevelChanges", "记住思考级别", true),
|
|
43
|
+
bool("btwCopy", "plugins", "piBtw", "fullscreenCopyOnSelect", "全屏选择时复制", true),
|
|
44
|
+
bool("mcpDirect", "plugins", "mcp", "settings.directTools", "直接暴露工具 schema", false),
|
|
45
|
+
bool("mcpNamespace", "plugins", "mcp", "settings.namespaceProxyTools", "工具名加服务前缀", true),
|
|
46
|
+
bool("mcpScript", "plugins", "mcp", "settings.scriptMode", "允许脚本模式", true),
|
|
47
|
+
integer("mcpIdle", "plugins", "mcp", "settings.idleTimeout", "空闲断开(分钟)", 0, limit, 10),
|
|
48
|
+
integer("mcpBytes", "plugins", "mcp", "settings.outputGuard.maxBytes", "最大输出字节", 1, limit, 51200),
|
|
49
|
+
integer("mcpLines", "plugins", "mcp", "settings.outputGuard.maxLines", "最大输出行数", 1, limit, 2000),
|
|
50
|
+
integer("mcpDetails", "plugins", "mcp", "settings.outputGuard.detailsMaxBytes", "详情最大字节", 1, limit, 16384),
|
|
51
|
+
integer("saConcurrent", "agents", "subagents", "maxConcurrent", "后台最大并发", 1, 1024, 10),
|
|
52
|
+
integer("saForeground", "agents", "subagents", "maxConcurrentForeground", "前台最大并发(0 无限制)", 0, 1024, 0),
|
|
53
|
+
integer("saTurns", "agents", "subagents", "defaultMaxTurns", "默认最大轮数(0 无限制)", 0, 10000, 0),
|
|
54
|
+
integer("saGrace", "agents", "subagents", "graceTurns", "宽限轮数", 1, 1000, 5),
|
|
55
|
+
integer("saDepth", "agents", "subagents", "maxSubagentDepth", "子代理最大深度", 0, 16, 2),
|
|
56
|
+
bool("saBackground", "agents", "subagents", "backgroundByDefault", "默认后台执行", true),
|
|
57
|
+
bool("saUsage", "agents", "subagents", "reportUsage", "显示使用量", false),
|
|
58
|
+
bool("saCost", "agents", "subagents", "showCost", "显示费用", false),
|
|
59
|
+
choice("webFetchMode", "web", "webSearch", "fetch.defaultMode", "默认抓取方式", ["readable", "raw", "answer"], "readable"),
|
|
60
|
+
{ id: "webFetchModes", group: "web", file: "webSearch", key: "fetch.allowedModes", label: "允许的抓取方式", kind: "string-list", options: ["readable", "raw", "answer"], nonempty: true, unique: true, default: ["readable", "raw", "answer"] },
|
|
61
|
+
{ id: "webAllowedProviders", group: "web", file: "webSearch", key: "webSearch.allowedProviders", label: "允许的搜索供应商", kind: "string-list", providerNames: true },
|
|
62
|
+
integer("webSummaryDeadline", "web", "webSearch", "summaryGenerationDeadlineMs", "摘要等待上限(毫秒)", 1, 600000),
|
|
63
|
+
text("webSummaryInstructions", "web", "webSearch", "summaryInstructions", "摘要补充指令"),
|
|
64
|
+
...["webSearch", "sourceCheck", "fetchContent", "getSearchContent"].map(name => bool("webTool_" + name, "web", "webSearch", "tools." + name + ".enabled", name + " 工具启用", true)),
|
|
65
|
+
text("rvModel", "review", "jev", "jevModel", "Jev 判定模型"),
|
|
66
|
+
choice("bhCompaction", "compression", "blackhole", "compaction", "自动压缩", ["auto", "off"], "auto"),
|
|
67
|
+
choice("bhEngine", "compression", "blackhole", "compactionEngine", "压缩引擎", ["blackhole", "pi-default"], "blackhole"),
|
|
68
|
+
bool("bhMemory", "compression", "blackhole", "memory", "观察记忆", false),
|
|
69
|
+
choice("bhSubagentMemory", "compression", "blackhole", "subagentMemory", "子代理记忆", ["off", "inherit", "on"], "off"),
|
|
70
|
+
bool("bhSessionFallback", "compression", "blackhole", "sessionFallback", "会话回退", false),
|
|
71
|
+
choice("bhTailBehavior", "compression", "blackhole", "tailBehavior", "尾部行为", ["pi-default", "preserve", "drop"], "pi-default"),
|
|
72
|
+
choice("bhPressureFallback", "compression", "blackhole", "contextPressureFallback", "上下文压力回退", ["off", "pi-default", "blackhole"], "off"),
|
|
73
|
+
{ id: "bhAfterRatio", group: "compression", file: "blackhole", key: "compactAfterRatio", label: "压缩触发比例", kind: "number", min: 0.1, max: 1, default: 0.65 },
|
|
74
|
+
integer("bhRetained", "compression", "blackhole", "retainedToolOutputMaxTokens", "保留工具输出", 0, limit, 30000),
|
|
75
|
+
integer("bhRecallChars", "compression", "blackhole", "recallResponseMaxChars", "召回响应上限", 0, limit, 64000),
|
|
76
|
+
bool("bhPreMessage", "compression", "blackhole", "showPreCompactionMessage", "压缩前提示", true),
|
|
77
|
+
choice("bhMidRun", "compression", "blackhole", "midRunCompaction", "运行中压缩", ["off", "on"], "off"),
|
|
78
|
+
bool("bhStatusBar", "compression", "blackhole", "statusBar", "状态栏显示", true),
|
|
79
|
+
bool("bhWorkerNotifications", "compression", "blackhole", "showWorkerNotifications", "显示工作线程通知", false),
|
|
80
|
+
].map(Object.freeze);
|
|
81
|
+
|
|
82
|
+
export const EXISTING_DEFAULTS = {
|
|
83
|
+
rvEnabled: true, rvTimeout: 4000, rvRetries: 1, rvMaxState: 120000, rvUncertain: "allow", rvGateScope: "all", rvDisplay: "compact",
|
|
84
|
+
pccPreviewLines: 3, fffHomeScan: true, fffWarnHomeScan: true, fffFollowSymlinks: true, btwLayout: "fullscreen", btwRatio: 0.5,
|
|
85
|
+
webDefault: "auto", webWorkflow: "none", webInlineCap: 30000, webFetchTimeout: 30, webToolActivation: "auto", webTrustProxy: false, webBrowserCookies: false,
|
|
86
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const SEARCH_PROVIDERS = ["openai", "brave", "parallel", "parallel-mcp", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "you", "firecrawl", "jina", "searxng", "degoog", "duckduckgo", "perplexity", "gemini", "kimi", "exa", "serpdive", "kagi", "ollama", "anysearch", "xai", "mistral", "brightdata", "serpbase", "serpapi", "serper", "serply", "valyu", "bocha", "xcrawl", "baizhi", "zai", "keenable", "ceramic", "deepseek", "linkup"];
|
|
2
|
+
export const ratio = v => typeof v === "string" && /^\d+(?:\.\d+)?%$/.test(v) ? Number(v.slice(0, -1)) / 100 : typeof v === "number" ? v : NaN;
|
|
3
|
+
export function pluginValueProblem(field, value) {
|
|
4
|
+
if (["webProxy"].includes(field.id) && /\[(?:敏感路径或参数已隐藏|地址已隐藏)\]/.test(value)) return "不能保存脱敏占位符,请输入完整新地址或保持原值";
|
|
5
|
+
if (field.file === "jev" && field.kind === "string-list" && (value.length > 200 || value.some(v => v.length > 300 || /[\r\n]/.test(v)))) return "最多200条,每条最多300字符且不能换行";
|
|
6
|
+
if (field.id === "rvModel" && value && !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(value)) return "需要有效 Jev 模型标识";
|
|
7
|
+
if (field.id === "btwModel" && value && value !== "inherit" && !/^[^\s/\x00-\x1f]+\/[^\s\x00-\x1f]+$/.test(value)) return "模型需要 provider/model 格式,不能含空白或控制字符";
|
|
8
|
+
if (field.providerNames && (!value.length || value.some(v => !SEARCH_PROVIDERS.includes(v)))) return "需要非空且有效的搜索供应商列表(不包含 auto/all)";
|
|
9
|
+
if (field.options && value.some(v => !field.options.includes(v))) return "列表包含插件不支持的选项";
|
|
10
|
+
if (field.nonempty && !value.length) return "列表不能为空";
|
|
11
|
+
if ((field.unique || field.providerNames) && new Set(value).size !== value.length) return "列表不能包含重复项";
|
|
12
|
+
if (field.required && !value.trim()) return "此字段不能为空";
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
export function documentProblem(fileKey, value) {
|
|
16
|
+
if (fileKey === "webSearch") {
|
|
17
|
+
if (value.toolExposure === "deferred" && value.toolActivation === "eager") return "延迟暴露工具不能使用 eager 激活";
|
|
18
|
+
if (value.toolActivation === "none" && value.toolExposure !== "deferred") return "none 激活需要 toolExposure 为 deferred";
|
|
19
|
+
const modes = value.fetch?.allowedModes ?? ["readable", "raw", "answer"];
|
|
20
|
+
if (!Array.isArray(modes) || !modes.length || new Set(modes).size !== modes.length || modes.some(v => !["readable", "raw", "answer"].includes(v))) return "fetch.allowedModes 需要非空、无重复的 readable/raw/answer 列表";
|
|
21
|
+
if (!modes.includes(value.fetch?.defaultMode ?? "readable")) return "默认抓取方式必须在允许列表内";
|
|
22
|
+
const selected = value.searchProvider ?? value.provider ?? "auto";
|
|
23
|
+
const providers = Array.isArray(selected) ? selected : [selected];
|
|
24
|
+
const allowed = value.webSearch?.allowedProviders;
|
|
25
|
+
if (allowed && providers.some(v => !["auto", "all"].includes(v) && !allowed.includes(v))) return "搜索供应商不在允许列表内";
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|