vc-extras 0.1.0 → 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 -71
- package/agent-install.mjs +159 -0
- package/agents/tester.md +23 -23
- package/install-extras.mjs +41 -109
- package/install-menu.mjs +22 -43
- package/install-skills.mjs +112 -112
- package/package.json +72 -28
- package/plugin-registry.mjs +73 -0
- package/plugins/config-ui/index.ts +159 -159
- package/plugins/config-ui/lib/arguments.mjs +24 -24
- package/plugins/config-ui/lib/documents.mjs +67 -67
- package/plugins/config-ui/lib/frontmatter.mjs +91 -91
- package/plugins/config-ui/lib/open.mjs +16 -16
- package/plugins/config-ui/lib/ownership.mjs +99 -99
- package/plugins/config-ui/lib/page.mjs +11 -11
- package/plugins/config-ui/lib/patch.mjs +35 -35
- package/plugins/config-ui/lib/paths.mjs +14 -14
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -86
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -28
- package/plugins/config-ui/lib/redaction.mjs +8 -8
- package/plugins/config-ui/lib/registry.mjs +282 -282
- package/plugins/config-ui/lib/secrets.mjs +44 -44
- package/plugins/config-ui/lib/server.mjs +250 -250
- package/plugins/config-ui/lib/sources.mjs +96 -96
- package/plugins/config-ui/lib/state.mjs +156 -156
- package/plugins/config-ui/lib/themes.mjs +113 -113
- package/plugins/config-ui/lib/writer.mjs +690 -690
- package/plugins/config-ui/project-local-owner.ts +106 -106
- package/plugins/config-ui/vc-extras.plugin.json +13 -0
- package/plugins/config-ui/web/app.mjs +997 -997
- package/plugins/config-ui/web/index.html +342 -342
- 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 -21
- package/skills/animate/RECIPES.md +324 -324
- package/skills/animate/SKILL.md +208 -208
- package/skills/animate/UPSTREAM.md +19 -19
- package/skills/animation-performance/LICENSE +21 -21
- package/skills/animation-performance/SKILL.md +223 -223
- package/skills/animation-performance/UPSTREAM.md +19 -19
- package/skills/answer-me-with-html/SKILL.md +174 -174
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -12896
- package/skills/apple-design/LICENSE +21 -21
- package/skills/apple-design/SKILL.md +291 -291
- package/skills/apple-design/UPSTREAM.md +19 -19
- package/skills/bad-smell/SKILL.md +44 -44
- package/skills/commit/SKILL.md +90 -90
- package/skills/emil-design-eng/LICENSE +21 -21
- package/skills/emil-design-eng/SKILL.md +677 -677
- package/skills/emil-design-eng/UPSTREAM.md +19 -19
- package/skills/find-the-truth/SKILL.md +38 -38
- package/skills/find-the-truth/references/trace-method.md +48 -48
- package/skills/find-the-truth/references/truth-method.md +39 -39
- package/skills/gestures/LICENSE +21 -21
- package/skills/gestures/SKILL.md +107 -107
- package/skills/gestures/UPSTREAM.md +19 -19
- package/skills/humanizer-zh/LICENSE +21 -21
- package/skills/humanizer-zh/SKILL.md +409 -409
- package/skills/humanizer-zh/UPSTREAM.md +7 -7
- package/skills/impeccable/LICENSE +191 -191
- package/skills/impeccable/NOTICE.md +11 -11
- package/skills/impeccable/SKILL.md +89 -89
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +8 -8
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -21
- package/skills/impeccable/reference/adapt.md +318 -318
- package/skills/impeccable/reference/adapt.native.md +58 -58
- package/skills/impeccable/reference/android.md +46 -46
- package/skills/impeccable/reference/animate.md +89 -89
- package/skills/impeccable/reference/audit.md +139 -139
- package/skills/impeccable/reference/audit.native.md +139 -139
- package/skills/impeccable/reference/bolder.md +33 -33
- package/skills/impeccable/reference/clarify.md +94 -94
- package/skills/impeccable/reference/colorize.md +86 -86
- package/skills/impeccable/reference/component-review.md +63 -63
- package/skills/impeccable/reference/craft-floor.md +44 -44
- package/skills/impeccable/reference/craft.md +5 -5
- package/skills/impeccable/reference/critique.md +819 -819
- package/skills/impeccable/reference/degraded/asset-producer.md +41 -41
- package/skills/impeccable/reference/degraded/documenter.md +23 -23
- package/skills/impeccable/reference/degraded/finish-reviewer.md +37 -37
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -92
- package/skills/impeccable/reference/delight.md +70 -70
- package/skills/impeccable/reference/distill.md +111 -111
- package/skills/impeccable/reference/doctor.md +54 -54
- package/skills/impeccable/reference/document.md +416 -416
- package/skills/impeccable/reference/extract.md +69 -69
- package/skills/impeccable/reference/generate.md +101 -101
- package/skills/impeccable/reference/harden.md +362 -362
- package/skills/impeccable/reference/hooks.md +114 -114
- package/skills/impeccable/reference/init.md +131 -131
- package/skills/impeccable/reference/ios.md +51 -51
- package/skills/impeccable/reference/layout.md +84 -84
- package/skills/impeccable/reference/live-setup.md +104 -104
- package/skills/impeccable/reference/live.md +327 -327
- package/skills/impeccable/reference/mode-operate.md +21 -21
- package/skills/impeccable/reference/mode-persuade.md +19 -19
- package/skills/impeccable/reference/mode-read.md +21 -21
- package/skills/impeccable/reference/new-work.md +152 -152
- package/skills/impeccable/reference/onboard.md +234 -234
- package/skills/impeccable/reference/operate.md +61 -61
- package/skills/impeccable/reference/optimize.md +257 -257
- package/skills/impeccable/reference/overdrive.md +127 -127
- package/skills/impeccable/reference/polish.md +105 -105
- package/skills/impeccable/reference/quieter.md +99 -99
- package/skills/impeccable/reference/region-map.md +26 -26
- package/skills/impeccable/reference/routing.md +24 -24
- package/skills/impeccable/reference/shape.md +59 -59
- package/skills/impeccable/reference/typeset.md +90 -90
- package/skills/impeccable/reference/visualize.md +47 -47
- package/skills/impeccable/scripts/VERSION +1 -1
- package/skills/impeccable/scripts/command-metadata.json +98 -98
- package/skills/impeccable/scripts/data/font-index-failures.json +120 -120
- package/skills/impeccable/scripts/engine-checksums.txt +9 -9
- package/skills/impeccable/scripts/impeccable +249 -249
- package/skills/impeccable/scripts/impeccable.cmd +278 -278
- package/skills/impeccable/scripts/live-browser-dom.js +320 -320
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -246
- package/skills/impeccable/scripts/live-browser-session.js +183 -183
- package/skills/impeccable/scripts/live-browser.js +13862 -13862
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -14
- package/skills/improve-animations/AUDIT.md +115 -115
- package/skills/improve-animations/LICENSE +21 -21
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -73
- package/skills/improve-animations/SKILL.md +110 -110
- package/skills/improve-animations/UPSTREAM.md +19 -19
- package/skills/pick-ui-library/LICENSE +21 -21
- package/skills/pick-ui-library/SKILL.md +85 -85
- package/skills/pick-ui-library/UPSTREAM.md +19 -19
- package/skills/review-animations/LICENSE +21 -21
- package/skills/review-animations/SKILL.md +120 -120
- package/skills/review-animations/STANDARDS.md +187 -187
- package/skills/review-animations/UPSTREAM.md +19 -19
- package/skills/test/SKILL.md +29 -29
- package/skills/test/references/test-method.md +60 -60
- package/skills/write-doc/SKILL.md +115 -115
- package/skills/write-doc/examples/result-report.md +53 -53
- package/skills/write-doc/examples/task-summary.md +45 -45
- package/skills/write-doc/references/terminology.md +147 -147
- package/specs/ask-host-protocol-v1.md +58 -0
- package/specs/design-demo.md +1102 -1102
- package/specs/frontend-immersive.md +28 -28
- package/specs/plugin-install-v2.md +123 -0
- package/specs/plugin-install.md +38 -0
- package/specs/web-modes/explore.md +31 -31
- package/specs/web-modes/risk.md +15 -15
- package/specs/web-modes/verify.md +16 -16
- package/vc-extras.mjs +46 -62
- package/plugins/essrj/context.ts +0 -47
- package/plugins/essrj/data.ts +0 -190
- package/plugins/essrj/index.ts +0 -139
- package/plugins/essrj/package.json +0 -12
- package/plugins/essrj/project-local-owner.ts +0 -106
- package/plugins/essrj/render.ts +0 -217
- package/plugins/essrj/types.ts +0 -40
- package/plugins.json +0 -38
|
@@ -1,282 +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
|
-
}
|
|
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
|
+
}
|