vc-extras 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -3
- package/agent-install.mjs +159 -0
- package/agents/tester.md +23 -0
- package/install-extras.mjs +66 -0
- package/install-menu.mjs +42 -0
- package/install-skills.mjs +112 -0
- package/package.json +72 -6
- package/plugin-registry.mjs +73 -0
- 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/vc-extras.plugin.json +13 -0
- package/plugins/config-ui/web/app.mjs +997 -0
- package/plugins/config-ui/web/index.html +342 -0
- package/plugins/pi-blackhole/vc-extras.plugin.json +12 -0
- package/plugins/pi-btw/vc-extras.plugin.json +12 -0
- package/plugins/pi-claude-code/vc-extras.plugin.json +12 -0
- package/plugins/pi-fff/vc-extras.plugin.json +12 -0
- package/plugins/pi-jev-auto-mode/vc-extras.plugin.json +12 -0
- package/plugins/pi-mcp-adapter/vc-extras.plugin.json +12 -0
- package/plugins/pi-web-access/vc-extras.plugin.json +12 -0
- package/plugins/vc-ask/claude-hook.mjs +37 -0
- package/plugins/vc-ask/codex-native.mjs +28 -0
- package/plugins/vc-ask/host-channel.mjs +75 -0
- package/plugins/vc-ask/index.ts +57 -0
- package/plugins/vc-ask/native-questions.mjs +33 -0
- package/plugins/vc-ask/package.json +10 -0
- package/plugins/vc-ask/payload.ts +170 -0
- package/plugins/vc-ask/questionnaire/LICENSE.ask-user-question +21 -0
- package/plugins/vc-ask/questionnaire/UPSTREAM.md +104 -0
- package/plugins/vc-ask/questionnaire/answer-channel.ts +135 -0
- package/plugins/vc-ask/questionnaire/config.ts +180 -0
- package/plugins/vc-ask/questionnaire/events.ts +154 -0
- package/plugins/vc-ask/questionnaire/execute.ts +688 -0
- package/plugins/vc-ask/questionnaire/i18n.ts +73 -0
- package/plugins/vc-ask/questionnaire/inline-entry.ts +312 -0
- package/plugins/vc-ask/questionnaire/locales/de.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/en.json +42 -0
- package/plugins/vc-ask/questionnaire/locales/es.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/fr.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt-BR.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/ru.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/uk.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/zh.json +46 -0
- package/plugins/vc-ask/questionnaire/presentation.ts +11 -0
- package/plugins/vc-ask/questionnaire/question-preview.ts +6 -0
- package/plugins/vc-ask/questionnaire/rpc.ts +221 -0
- package/plugins/vc-ask/questionnaire/session-timeout.ts +67 -0
- package/plugins/vc-ask/questionnaire/state/build-questionnaire.ts +144 -0
- package/plugins/vc-ask/questionnaire/state/external-editor.ts +62 -0
- package/plugins/vc-ask/questionnaire/state/geometry.ts +131 -0
- package/plugins/vc-ask/questionnaire/state/key-router.ts +382 -0
- package/plugins/vc-ask/questionnaire/state/panel-router.ts +32 -0
- package/plugins/vc-ask/questionnaire/state/questionnaire-session.ts +642 -0
- package/plugins/vc-ask/questionnaire/state/row-intent.ts +143 -0
- package/plugins/vc-ask/questionnaire/state/selectors/contract.ts +24 -0
- package/plugins/vc-ask/questionnaire/state/selectors/derivations.ts +40 -0
- package/plugins/vc-ask/questionnaire/state/selectors/focus.ts +17 -0
- package/plugins/vc-ask/questionnaire/state/selectors/projections.ts +99 -0
- package/plugins/vc-ask/questionnaire/state/state-reducer.ts +455 -0
- package/plugins/vc-ask/questionnaire/state/state.ts +90 -0
- package/plugins/vc-ask/questionnaire/state/vertical.ts +158 -0
- package/plugins/vc-ask/questionnaire/timeout.ts +59 -0
- package/plugins/vc-ask/questionnaire/tool/external-answer.ts +103 -0
- package/plugins/vc-ask/questionnaire/tool/format-answer.ts +24 -0
- package/plugins/vc-ask/questionnaire/tool/normalize-params.ts +37 -0
- package/plugins/vc-ask/questionnaire/tool/response-envelope.ts +75 -0
- package/plugins/vc-ask/questionnaire/tool/types.ts +74 -0
- package/plugins/vc-ask/questionnaire/tool/validate-questionnaire.ts +75 -0
- package/plugins/vc-ask/questionnaire/view/card-theme.ts +245 -0
- package/plugins/vc-ask/questionnaire/view/components/inline-input.ts +66 -0
- package/plugins/vc-ask/questionnaire/view/components/multi-select-view.ts +177 -0
- package/plugins/vc-ask/questionnaire/view/components/option-list-view.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/markdown-content-cache.ts +101 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-block-renderer.ts +130 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-box-renderer.ts +86 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-layout-decider.ts +204 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-pane.ts +257 -0
- package/plugins/vc-ask/questionnaire/view/components/submit-picker.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/tab-bar.ts +57 -0
- package/plugins/vc-ask/questionnaire/view/components/wrapping-select.ts +269 -0
- package/plugins/vc-ask/questionnaire/view/dialog-builder.ts +319 -0
- package/plugins/vc-ask/questionnaire/view/document-theme.ts +53 -0
- package/plugins/vc-ask/questionnaire/view/document-view.ts +306 -0
- package/plugins/vc-ask/questionnaire/view/panel-chrome.ts +133 -0
- package/plugins/vc-ask/questionnaire/view/props-adapter.ts +77 -0
- package/plugins/vc-ask/questionnaire/view/stateful-view.ts +24 -0
- package/plugins/vc-ask/questionnaire/view/tab-components.ts +16 -0
- package/plugins/vc-ask/questionnaire/view/tab-content-strategy.ts +280 -0
- package/plugins/vc-ask/questionnaire/view/vertical-view.ts +218 -0
- package/plugins/vc-ask/user-input-events.ts +34 -0
- package/plugins/vc-ask/vc-extras.plugin.json +18 -0
- package/plugins/vc-footer/agents/claude-code/adapter.mjs +29 -0
- package/plugins/vc-footer/agents/claude-code/cli.mjs +23 -0
- package/plugins/vc-footer/agents/claude-code/renderer.mjs +1 -0
- package/plugins/vc-footer/agents/claude-code/types.d.ts +38 -0
- package/plugins/vc-footer/agents/codex/adapter.mjs +13 -0
- package/plugins/vc-footer/agents/codex/mcp.mjs +45 -0
- package/plugins/vc-footer/agents/codex/native.mjs +19 -0
- package/plugins/vc-footer/agents/codex/renderer.mjs +2 -0
- package/plugins/vc-footer/agents/pi/adapter.mjs +23 -0
- package/plugins/vc-footer/agents/pi/index.js +84 -0
- package/plugins/vc-footer/agents/pi/project-local-owner.mjs +97 -0
- package/plugins/vc-footer/agents/pi/renderer.mjs +5 -0
- package/plugins/vc-footer/core/data.mjs +218 -0
- package/plugins/vc-footer/core/render.mjs +291 -0
- package/plugins/vc-footer/core/types.d.ts +29 -0
- package/plugins/vc-footer/package.json +22 -0
- package/plugins/vc-footer/vc-extras.plugin.json +32 -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/ask-host-protocol-v1.md +58 -0
- package/specs/design-demo.md +1102 -0
- package/specs/frontend-immersive.md +28 -0
- package/specs/plugin-install-v2.md +123 -0
- package/specs/plugin-install.md +38 -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 +62 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// The field registry is the single source of truth behind the browser form: every
|
|
2
|
+
// form control names the file and the key path it owns, so what the page shows,
|
|
3
|
+
// what the diff previews and what the writer commits can never drift apart.
|
|
4
|
+
//
|
|
5
|
+
// Two kinds of secrets exist and they belong in different places:
|
|
6
|
+
// - Pi's own credentials live in <agentDir>/auth.json (keyed by provider);
|
|
7
|
+
// - plugin keys must live in that plugin's own config file, because the plugin
|
|
8
|
+
// reads nothing else (pi-web-access reads `braveApiKey` from web-search.json).
|
|
9
|
+
// Putting a plugin key in auth.json would look saved and change nothing.
|
|
10
|
+
import * as fs from "node:fs";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import { webConfigPath, mcpConfigPath } from "./sources.mjs";
|
|
13
|
+
import { PLUGIN_FIELDS } from "./plugin-fields.mjs";
|
|
14
|
+
import { SEARCH_PROVIDERS } from "./plugin-validation.mjs";
|
|
15
|
+
|
|
16
|
+
const agentFile = (c, name) => path.join(c.agentDir, name);
|
|
17
|
+
const projectFile = (c, name) => path.join(c.projectRoot, name);
|
|
18
|
+
|
|
19
|
+
export const FILES = {
|
|
20
|
+
jev: {
|
|
21
|
+
sample: "~/.pi/agent/jev-auto-mode.json",
|
|
22
|
+
scope: "user",
|
|
23
|
+
kind: "json",
|
|
24
|
+
resolve: (c) => agentFile(c, "jev-auto-mode.json"),
|
|
25
|
+
},
|
|
26
|
+
jevPolicy: {
|
|
27
|
+
sample: "~/.pi/agent/jev-auto-mode-policy.md",
|
|
28
|
+
scope: "user",
|
|
29
|
+
kind: "text",
|
|
30
|
+
resolve: (c) => agentFile(c, "jev-auto-mode-policy.md"),
|
|
31
|
+
},
|
|
32
|
+
piSettings: {
|
|
33
|
+
sample: "~/.pi/agent/settings.json",
|
|
34
|
+
scope: "user",
|
|
35
|
+
kind: "json",
|
|
36
|
+
resolve: (c) => agentFile(c, "settings.json"),
|
|
37
|
+
},
|
|
38
|
+
blackhole: {
|
|
39
|
+
sample: "~/.pi/agent/pi-blackhole/pi-blackhole-config.json",
|
|
40
|
+
scope: "user",
|
|
41
|
+
kind: "json",
|
|
42
|
+
resolve: (c) => agentFile(c, path.join("pi-blackhole", "pi-blackhole-config.json")),
|
|
43
|
+
},
|
|
44
|
+
models: {
|
|
45
|
+
sample: "~/.pi/agent/models.json",
|
|
46
|
+
scope: "user",
|
|
47
|
+
kind: "json",
|
|
48
|
+
resolve: (c) => agentFile(c, "models.json"),
|
|
49
|
+
},
|
|
50
|
+
auth: {
|
|
51
|
+
sample: "~/.pi/agent/auth.json",
|
|
52
|
+
scope: "user",
|
|
53
|
+
kind: "credentials",
|
|
54
|
+
mode: 0o600,
|
|
55
|
+
resolve: (c) => agentFile(c, "auth.json"),
|
|
56
|
+
},
|
|
57
|
+
webSearch: {
|
|
58
|
+
sample: "~/.pi/agent/web-search.json",
|
|
59
|
+
scope: "user",
|
|
60
|
+
kind: "json",
|
|
61
|
+
resolve: webConfigPath,
|
|
62
|
+
dynamic: true,
|
|
63
|
+
mode: 0o600,
|
|
64
|
+
},
|
|
65
|
+
// ---------- 插件与 MCP ----------
|
|
66
|
+
piFff: {
|
|
67
|
+
sample: "~/.pi/agent/pi-fff.json",
|
|
68
|
+
scope: "user",
|
|
69
|
+
kind: "json",
|
|
70
|
+
resolve: (c) => agentFile(c, "pi-fff.json"),
|
|
71
|
+
},
|
|
72
|
+
piBtw: {
|
|
73
|
+
sample: "~/.pi/agent/pi-btw.json",
|
|
74
|
+
scope: "user",
|
|
75
|
+
kind: "json",
|
|
76
|
+
resolve: (c) => agentFile(c, "pi-btw.json"),
|
|
77
|
+
},
|
|
78
|
+
mcp: {
|
|
79
|
+
sample: "由已安装 MCP 解析路径",
|
|
80
|
+
scope: "user",
|
|
81
|
+
kind: "jsonc",
|
|
82
|
+
dynamic: true,
|
|
83
|
+
mode: 0o600,
|
|
84
|
+
resolve: mcpConfigPath,
|
|
85
|
+
},
|
|
86
|
+
piCcExtensions: {
|
|
87
|
+
sample: "~/.pi/agent/pi-cc-extensions.json",
|
|
88
|
+
scope: "user",
|
|
89
|
+
kind: "json",
|
|
90
|
+
resolve: (c) => agentFile(c, "pi-cc-extensions.json"),
|
|
91
|
+
},
|
|
92
|
+
// ---------- 子代理 ----------
|
|
93
|
+
subagents: {
|
|
94
|
+
sample: "~/.pi/agent/subagents.json",
|
|
95
|
+
scope: "user",
|
|
96
|
+
kind: "json",
|
|
97
|
+
resolve: (c) => agentFile(c, "subagents.json"),
|
|
98
|
+
projectOverrides: (c) => [projectFile(c, ".pi/subagents.json")],
|
|
99
|
+
},
|
|
100
|
+
roleExplorer: roleFile("explorer"),
|
|
101
|
+
roleResearcher: roleFile("researcher"),
|
|
102
|
+
roleReviewer: roleFile("reviewer"),
|
|
103
|
+
roleTester: roleFile("tester"),
|
|
104
|
+
roleExpert: roleFile("expert"),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// User roles are shared defaults; project .agents/agents and .pi/agents retain
|
|
108
|
+
// upstream precedence. The editor only touches its two frontmatter keys.
|
|
109
|
+
function roleFile(name) {
|
|
110
|
+
const builtin = (c) => {
|
|
111
|
+
// Tester belongs to vc-extras, not Emma. This independently installed plugin
|
|
112
|
+
// does not bundle that role; never synthesize it from a different role source.
|
|
113
|
+
if (name === "tester") return null;
|
|
114
|
+
const installed = agentFile(c, path.join("vc-packages", "current", "emma", "workflow", "agents", `${name}.md`));
|
|
115
|
+
return fs.existsSync(installed) ? installed : agentFile(c, path.join("emma", "agents", `${name}.md`));
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
sample: `~/.pi/agent/agents/${name}.md`,
|
|
119
|
+
scope: "user",
|
|
120
|
+
kind: "frontmatter",
|
|
121
|
+
builtin,
|
|
122
|
+
projectOverrides: (c) => [projectFile(c, `.pi/agents/${name}.md`), projectFile(c, `.agents/agents/${name}.md`)],
|
|
123
|
+
resolve: (c) => agentFile(c, path.join("agents", `${name}.md`)),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// `thinking` lives in the file as low/medium/high; the page shows 低/中/高 through its
|
|
128
|
+
// three-bar signal meter.
|
|
129
|
+
export const THINKING_LEVELS = ["low", "medium", "high"];
|
|
130
|
+
|
|
131
|
+
// The five roles the page lists, in the order the design shows them.
|
|
132
|
+
export const ROLE_NAMES = ["Explorer", "Researcher", "Reviewer", "Tester", "Expert"];
|
|
133
|
+
|
|
134
|
+
export const roleFileKey = (name) => `role${name}`;
|
|
135
|
+
|
|
136
|
+
// pi-jev-auto-mode's calibrated defaults. The thresholds are per-rule confidence
|
|
137
|
+
// bars: a rule the engine scores below its bar counts as not satisfied.
|
|
138
|
+
export const JEV_THRESHOLD_RULES = [
|
|
139
|
+
{ id: "thIntent", key: "intent_coverage", label: "意图一致", calibrated: 0.6 },
|
|
140
|
+
{ id: "thPolicy", key: "policy_compliance", label: "符合策略", calibrated: 0.8 },
|
|
141
|
+
{ id: "thLocal", key: "local_scope", label: "局部操作", calibrated: 0.9 },
|
|
142
|
+
{ id: "thSecret", key: "no_secret_egress", label: "无密钥外泄", calibrated: 0.97 },
|
|
143
|
+
{ id: "thDamage", key: "no_irreversible_damage", label: "无不可逆破坏", calibrated: 0.8 },
|
|
144
|
+
{ id: "thOutward", key: "no_outward_effect", label: "无对外影响", calibrated: 0.9 },
|
|
145
|
+
{ id: "thPath", key: "path_not_protected", label: "路径未受保护", calibrated: 0.9 },
|
|
146
|
+
{ id: "thFetch", key: "no_fetched_code_execution", label: "不执行取回代码", calibrated: 0.9 },
|
|
147
|
+
{ id: "thInject", key: "prompt_injection_absent", label: "无提示注入", calibrated: 0.8 },
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
export const WEB_PROVIDER_KEYS = [
|
|
151
|
+
{ id: "brave", key: "braveApiKey" },
|
|
152
|
+
{ id: "exa", key: "exaApiKey" },
|
|
153
|
+
{ id: "tavily", key: "tavilyApiKey" },
|
|
154
|
+
{ id: "serper", key: "serperApiKey" },
|
|
155
|
+
{ id: "jina", key: "jinaApiKey" },
|
|
156
|
+
{ id: "firecrawl", key: "firecrawlApiKey" },
|
|
157
|
+
{ id: "perplexity", key: "perplexityApiKey" },
|
|
158
|
+
{ id: "openai", key: "openaiApiKey" },
|
|
159
|
+
{ id: "gemini", key: "geminiApiKey" },
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const field = (value) => Object.freeze(value);
|
|
163
|
+
|
|
164
|
+
export const FIELDS = Object.freeze([
|
|
165
|
+
// ---------- 命令评审: pi-jev-auto-mode ----------
|
|
166
|
+
field({ id: "rvEnabled", group: "review", label: "启用", file: "jev", key: "enabled", kind: "boolean" }),
|
|
167
|
+
field({ id: "rvTimeout", group: "review", label: "判定超时", file: "jev", key: "timeoutMs", kind: "integer", min: 250, max: 60000 }),
|
|
168
|
+
field({ id: "rvRetries", group: "review", label: "失败重试", file: "jev", key: "maxRetries", kind: "integer", min: 0, max: 5 }),
|
|
169
|
+
field({ id: "rvMaxState", group: "review", label: "状态上限", file: "jev", key: "maxStateCharacters", kind: "integer", min: 1000, max: 1000000 }),
|
|
170
|
+
field({ id: "rvUncertain", group: "review", label: "中间带", file: "jev", key: "uncertain", kind: "enum", values: ["deny", "ask", "allow"] }),
|
|
171
|
+
field({ id: "rvGateScope", group: "review", label: "语义覆盖面", file: "jev", key: "gateScope", kind: "enum", values: ["all", "matched"] }),
|
|
172
|
+
field({ id: "rvDisplay", group: "review", label: "记录展示", file: "jev", key: "display", kind: "enum", values: ["compact", "full"] }),
|
|
173
|
+
field({ id: "rvSafeCommands", group: "review", label: "免记录放行", file: "jev", key: "safeCommands", kind: "string-list" }),
|
|
174
|
+
field({ id: "rvAllowedCommands", group: "review", label: "总能过", file: "jev", key: "allowedCommands", kind: "string-list" }),
|
|
175
|
+
field({ id: "rvDisallowedCommands", group: "review", label: "直接拦", file: "jev", key: "disallowedCommands", kind: "string-list" }),
|
|
176
|
+
field({ id: "rvProtectedPaths", group: "review", label: "写入即评审", file: "jev", key: "extraProtectedPaths", kind: "string-list" }),
|
|
177
|
+
field({ id: "rvPolicy", group: "review", label: "补充约束", file: "jevPolicy", kind: "text", maxLength: 8000 }),
|
|
178
|
+
...JEV_THRESHOLD_RULES.map((rule) =>
|
|
179
|
+
field({ id: rule.id, group: "review", label: rule.label, file: "jev", key: `thresholds.${rule.key}`, kind: "number", min: 0.5, exclusiveMin: true, max: 1 })),
|
|
180
|
+
|
|
181
|
+
// ---------- Pi 核心: <agentDir>/settings.json ----------
|
|
182
|
+
field({ id: "defProvider", group: "pi-core", label: "默认 Provider", file: "piSettings", key: "defaultProvider", kind: "text" }),
|
|
183
|
+
field({ id: "defModel", group: "pi-core", label: "默认模型", file: "piSettings", key: "defaultModel", kind: "text" }),
|
|
184
|
+
field({ id: "defThinking", group: "pi-core", label: "思考等级", file: "piSettings", key: "defaultThinkingLevel", kind: "enum", values: ["off", "minimal", "low", "medium", "high", "xhigh", "max"] }),
|
|
185
|
+
field({ id: "enabledModels", group: "pi-core", label: "启用列表", file: "piSettings", key: "enabledModels", kind: "string-list" }),
|
|
186
|
+
field({ id: "cpReserve", group: "pi-core", label: "预留 tokens", file: "piSettings", key: "compaction.reserveTokens", kind: "integer", min: 1024, max: 1000000 }),
|
|
187
|
+
field({ id: "cpKeepRecent", group: "pi-core", label: "保留最近 tokens", file: "piSettings", key: "compaction.keepRecentTokens", kind: "integer", min: 1024, max: 1000000 }),
|
|
188
|
+
field({ id: "cpEnabled", group: "pi-core", label: "启用", file: "piSettings", key: "compaction.enabled", kind: "boolean" }),
|
|
189
|
+
field({ id: "piTheme", group: "appearance", label: "主题", file: "piSettings", key: "theme", kind: "theme", help: "列出 Pi 当前可加载的主题;保存后立即应用到当前会话,并写入 settings.json。" }),
|
|
190
|
+
|
|
191
|
+
// ---------- 模型与凭据: providers (non-secret) + credentials ----------
|
|
192
|
+
// models.json keys providers by id: { "<id>": { baseUrl, api, models: [{ id }] } }.
|
|
193
|
+
// The display name is cosmetic and stays in the page, and the provider key lives
|
|
194
|
+
// in auth.json, so neither is written back here.
|
|
195
|
+
field({ id: "providerRegistry", group: "model", label: "供应商注册", file: "models", key: "providers", kind: "providers" }),
|
|
196
|
+
field({ id: "credentialChanges", group: "model", label: "Pi 凭据", file: "auth", kind: "credentials" }),
|
|
197
|
+
|
|
198
|
+
// ---------- 联网检索 ----------
|
|
199
|
+
// The keys and value spaces here follow pi-web-access' documented schema
|
|
200
|
+
// (`pi-web-access/README.md`, "Configuration"): the default provider is the
|
|
201
|
+
// top-level `provider` (not `searchRouting.default`), the proxy is top-level
|
|
202
|
+
// `proxy`, `summaryModel` is the curator/auto-summary model (while
|
|
203
|
+
// `fetch.answerProvider` + `fetch.answerModel` are a pair for fetch_content answer
|
|
204
|
+
// mode), `allowBrowserCookies` is a top-level boolean (`authFetch` is a profile map),
|
|
205
|
+
// `ssrf.allowRanges` must be a string array (the plugin throws on a string), and
|
|
206
|
+
// `toolActivation` accepts auto/dynamic/eager.
|
|
207
|
+
field({ id: "webDefault", group: "web", label: "自动选择", file: "webSearch", key: "searchProvider", kind: "provider-selection", values: ["auto", "all", ...SEARCH_PROVIDERS] }),
|
|
208
|
+
field({ id: "webProxy", group: "web", label: "代理", file: "webSearch", key: "proxy", kind: "text" }),
|
|
209
|
+
field({ id: "webSummaryModel", group: "web", label: "摘要模型", file: "webSearch", key: "summaryModel", kind: "text", empty: "inherit" }),
|
|
210
|
+
field({ id: "webWorkflow", group: "web", label: "检索流程", file: "webSearch", key: "workflow", kind: "enum", values: ["none", "summary-review", "auto-summary"] }),
|
|
211
|
+
field({ id: "webInlineCap", group: "web", label: "正文上限", file: "webSearch", key: "maxInlineContentChars", kind: "integer", min: 1000, max: 200000 }),
|
|
212
|
+
field({ id: "webFetchTimeout", group: "web", label: "抓取超时", file: "webSearch", key: "fetch.timeout", kind: "number", min: 0, exclusiveMin: true, max: Number.MAX_SAFE_INTEGER }),
|
|
213
|
+
field({ id: "webToolActivation", group: "web", label: "动态激活", file: "webSearch", key: "toolActivation", kind: "enum", values: ["auto", "dynamic", "eager", "none"] }),
|
|
214
|
+
field({ id: "webSsrfRanges", group: "web", label: "SSRF 放行", file: "webSearch", key: "ssrf.allowRanges", kind: "string-list" }),
|
|
215
|
+
field({ id: "webTrustProxy", group: "web", label: "信任环境代理", file: "webSearch", key: "ssrf.trustEnvProxy", kind: "boolean" }),
|
|
216
|
+
field({ id: "webBrowserCookies", group: "web", label: "浏览器 Cookie", file: "webSearch", key: "allowBrowserCookies", kind: "boolean" }),
|
|
217
|
+
...WEB_PROVIDER_KEYS.map((entry) =>
|
|
218
|
+
field({ id: `webKey_${entry.id}`, group: "web", label: `${entry.id} API 密钥`, file: "webSearch", key: entry.key, kind: "secret" })),
|
|
219
|
+
|
|
220
|
+
// ---------- 插件与 MCP ----------
|
|
221
|
+
field({ id: "fffHomeScan", group: "plugins", label: "主页扫描", file: "piFff", key: "enableHomeDirScanning", kind: "boolean" }),
|
|
222
|
+
field({ id: "fffWarnHomeScan", group: "plugins", label: "扫描告警", file: "piFff", key: "warnOnHomeDirScan", kind: "boolean" }),
|
|
223
|
+
field({ id: "fffFollowSymlinks", group: "plugins", label: "跟随符号链接", file: "piFff", key: "followSymlinks", kind: "boolean" }),
|
|
224
|
+
// The picker's "跟随当前会话模型" is the plugin's own "no override" state: the key is
|
|
225
|
+
// removed rather than filled with the literal sentinel, which pi-btw would reject as
|
|
226
|
+
// an invalid model reference and treat the whole settings file as invalid.
|
|
227
|
+
field({ id: "btwModel", group: "plugins", label: "侧模型", file: "piBtw", key: "model", kind: "text", maxLength: 400, empty: "inherit" }),
|
|
228
|
+
field({ id: "btwLayout", group: "plugins", label: "布局", file: "piBtw", key: "layout", kind: "enum", values: ["fullscreen", "left-pane", "right-pane"] }),
|
|
229
|
+
// The file stores a 0.2–0.8 fraction; the page shows the same value as a percentage.
|
|
230
|
+
field({ id: "btwRatio", group: "plugins", label: "侧栏占比", file: "piBtw", key: "sidePaneRatio", kind: "number", min: 0.2, max: 0.8, page: "percent" }),
|
|
231
|
+
field({ id: "mcpServers", group: "plugins", label: "服务", file: "mcp", key: "mcpServers", kind: "mcp-servers" }),
|
|
232
|
+
|
|
233
|
+
...PLUGIN_FIELDS,
|
|
234
|
+
|
|
235
|
+
// ---------- 子代理 ----------
|
|
236
|
+
field({ id: "saDisableDefaults", group: "agents", label: "禁用默认角色", file: "subagents", key: "disableDefaultAgents", kind: "boolean" }),
|
|
237
|
+
field({ id: "saFallback", group: "agents", label: "未知角色回落", file: "subagents", key: "fallbackSubagent", kind: "enum", values: ["none", "general-purpose"] }),
|
|
238
|
+
field({ id: "saWorkflows", group: "agents", label: "工作流脚本", file: "subagents", key: "workflowsEnabled", kind: "boolean" }),
|
|
239
|
+
...ROLE_NAMES.flatMap((name) => [
|
|
240
|
+
field({ id: `role${name}Model`, group: "agents", label: `${name} 模型`, file: roleFileKey(name), key: "model", kind: "text", maxLength: 400, empty: "inherit" }),
|
|
241
|
+
field({ id: `role${name}Thinking`, group: "agents", label: `${name} 思考级别`, file: roleFileKey(name), key: "thinking", kind: "enum", values: THINKING_LEVELS }),
|
|
242
|
+
]),
|
|
243
|
+
|
|
244
|
+
]);
|
|
245
|
+
|
|
246
|
+
const BY_ID = new Map(FIELDS.map((entry) => [entry.id, entry]));
|
|
247
|
+
|
|
248
|
+
export function fieldById(id) {
|
|
249
|
+
return BY_ID.get(id) ?? null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function isReadonly(field) {
|
|
253
|
+
return field.strategy === "readonly";
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// A field whose file is a frontmatter document is written through the document-level
|
|
257
|
+
// editor, not the JSON one; `key` names a top-level YAML key there.
|
|
258
|
+
export function isFrontmatter(field) {
|
|
259
|
+
return FILES[field.file]?.kind === "frontmatter";
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function fileDefinition(fileKey) {
|
|
263
|
+
const definition = FILES[fileKey];
|
|
264
|
+
if (!definition) throw new Error(`Unknown config file: ${fileKey}`);
|
|
265
|
+
return definition;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// A field's key is a dotted path; `thresholds.intent_coverage` writes one level in.
|
|
269
|
+
export function keyPath(field) {
|
|
270
|
+
return field.key ? field.key.split(".") : [];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function readField(container, field) {
|
|
274
|
+
if (field.id === "webDefault") return container.searchProvider ?? container.provider;
|
|
275
|
+
if (field.kind === "mcp-servers") return container.mcpServers ?? container["mcp-servers"];
|
|
276
|
+
let current = container;
|
|
277
|
+
for (const segment of keyPath(field)) {
|
|
278
|
+
if (current === null || typeof current !== "object") return undefined;
|
|
279
|
+
current = current[segment];
|
|
280
|
+
}
|
|
281
|
+
return current;
|
|
282
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Two different secret stores, on purpose:
|
|
2
|
+
// - Pi's own provider credentials live in <agentDir>/auth.json and are keyed by
|
|
3
|
+
// provider; a write merges that one provider and leaves every other entry byte
|
|
4
|
+
// for byte alone.
|
|
5
|
+
// - Plugin keys belong to the plugin's own config file (handled by the writer),
|
|
6
|
+
// because a plugin never reads auth.json.
|
|
7
|
+
// Nothing here ever prints a key: diffs carry a mask, and the value only exists in
|
|
8
|
+
// the file being written.
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
|
|
11
|
+
export const MASK = "••••••••";
|
|
12
|
+
|
|
13
|
+
export function maskSecret(value) {
|
|
14
|
+
return typeof value === "string" && value !== "" ? MASK : "(未设置)";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function readCredentials(file) {
|
|
18
|
+
if (!fs.existsSync(file)) return {};
|
|
19
|
+
const raw = fs.readFileSync(file, "utf8");
|
|
20
|
+
try {
|
|
21
|
+
const value = JSON.parse(raw.replace(/^\uFEFF/, ""));
|
|
22
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23
|
+
} catch {
|
|
24
|
+
throw new Error(`无法解析 ${file}:请先修正该文件的 JSON 语法`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A credential entry keeps the shape already on disk (Pi versions differ in which
|
|
29
|
+
// fields they store), and an unknown shape is refused instead of guessed.
|
|
30
|
+
export function mergeCredentials(current, wanted) {
|
|
31
|
+
const next = { ...current };
|
|
32
|
+
for (const [provider, value] of Object.entries(wanted)) {
|
|
33
|
+
if (!value || typeof value.key !== "string" || value.key === "") continue;
|
|
34
|
+
const existing = current[provider];
|
|
35
|
+
if (existing && typeof existing !== "object") throw new Error(`auth.json 中 ${provider} 的条目不是对象,拒绝覆盖`);
|
|
36
|
+
// A stored entry decides its own shape. Only an api_key entry can be replaced by a
|
|
37
|
+
// pasted key; anything else (oauth and future types) needs its own flow, so it is
|
|
38
|
+
// reported instead of being overwritten with a key it cannot use.
|
|
39
|
+
const type = existing?.type ?? value.type;
|
|
40
|
+
if (typeof type !== "string" || type === "") throw new Error(`无法确定 ${provider} 的凭据类型,拒绝写入 auth.json`);
|
|
41
|
+
if (type !== "api_key") throw new Error(`auth.json 中 ${provider} 是 ${type} 类型的凭据,不能用 API 密钥覆盖`);
|
|
42
|
+
next[provider] = { ...(existing ?? {}), type, key: value.key };
|
|
43
|
+
}
|
|
44
|
+
return next;
|
|
45
|
+
}
|