@herbertgao/pi-extensions 2026.8.1 → 2026.8.2
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 +5 -2
- package/node_modules/@czottmann/pi-automode/README.md +16 -2
- package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +35 -0
- package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +18 -9
- package/node_modules/@czottmann/pi-automode/docs/defaults.md +6 -2
- package/node_modules/@czottmann/pi-automode/examples/automode.local.json +6 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +11 -7
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +100 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +32 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +78 -3
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +16 -4
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/paths.ts +23 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/permissions.ts +22 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/types.ts +18 -2
- package/node_modules/@czottmann/pi-automode/package.json +4 -4
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-audit.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-gain.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-help.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-review.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail-frontmatter.cjs +23 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +99 -0
- package/node_modules/@dietrichgebert/ponytail/.qoder/rules/ponytail.md +30 -0
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +16 -0
- package/node_modules/@dietrichgebert/ponytail/AGENTS.md +32 -0
- package/node_modules/@dietrichgebert/ponytail/LICENSE +21 -0
- package/node_modules/@dietrichgebert/ponytail/README.es.md +298 -0
- package/node_modules/@dietrichgebert/ponytail/README.ko.md +315 -0
- package/node_modules/@dietrichgebert/ponytail/README.md +351 -0
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-3model.svg +21 -0
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-agentic.svg +62 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.svg +115 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt-dark.svg +27 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt.svg +27 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/social-preview.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-es.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-ko.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +44 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +21 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +96 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +169 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-instructions.js +98 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +130 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +85 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.ps1 +24 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.sh +18 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-subagent.js +77 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/qoder-hooks.json +26 -0
- package/node_modules/@dietrichgebert/ponytail/package.json +47 -0
- package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +211 -0
- package/node_modules/@dietrichgebert/ponytail/pi-extension/package.json +8 -0
- package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +60 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +120 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-audit/SKILL.md +41 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +44 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +50 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +71 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-review/SKILL.md +57 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -3
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +10 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary.ts +6 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +24 -83
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/markdown-enhance.ts +119 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +73 -9
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-hover.ts +130 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-interaction.ts +65 -542
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-layout.ts +160 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-packets.ts +143 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-scroll.ts +184 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-diff/diff-renderer.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-grouping.ts +9 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-refresh.ts +91 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/agent-summary.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +1 -0
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +2 -2
- package/node_modules/@herbertgao/pi-stash/README.md +9 -9
- package/node_modules/@herbertgao/pi-stash/package.json +1 -1
- package/node_modules/@herbertgao/pi-stash/src/index.ts +2 -1
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +14 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +6 -2
- package/node_modules/@herbertgao/pi-subagents/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +85 -11
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +28 -4
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +12 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +2 -0
- package/node_modules/@narumitw/pi-btw/LICENSE +21 -0
- package/node_modules/@narumitw/pi-btw/README.md +210 -0
- package/node_modules/@narumitw/pi-btw/package.json +53 -0
- package/node_modules/@narumitw/pi-btw/src/bring-to-main.ts +632 -0
- package/node_modules/@narumitw/pi-btw/src/btw.ts +996 -0
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +339 -0
- package/node_modules/@narumitw/pi-btw/src/index.ts +1 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +296 -0
- package/node_modules/@narumitw/pi-btw/src/settings.ts +237 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +238 -0
- package/node_modules/@narumitw/pi-btw/src/text.ts +10 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +620 -0
- package/node_modules/@pi-plugins/fast-mode/LICENSE +21 -0
- package/node_modules/@pi-plugins/fast-mode/README.md +92 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts +6 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +2026 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -0
- package/node_modules/@pi-plugins/fast-mode/package.json +73 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +59 -0
- package/node_modules/pi-mcp-adapter/README.md +62 -13
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +377 -0
- package/node_modules/pi-mcp-adapter/commands.ts +9 -7
- package/node_modules/pi-mcp-adapter/config.ts +110 -49
- package/node_modules/pi-mcp-adapter/direct-tools.ts +34 -19
- package/node_modules/pi-mcp-adapter/elicitation-handler.ts +37 -36
- package/node_modules/pi-mcp-adapter/errors.ts +21 -17
- package/node_modules/pi-mcp-adapter/host-html-template.ts +13 -7
- package/node_modules/pi-mcp-adapter/index.ts +37 -14
- package/node_modules/pi-mcp-adapter/init.ts +9 -7
- package/node_modules/pi-mcp-adapter/json-schema-validator.ts +2 -2
- package/node_modules/pi-mcp-adapter/lifecycle.ts +8 -8
- package/node_modules/pi-mcp-adapter/logger.ts +1 -1
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +36 -22
- package/node_modules/pi-mcp-adapter/mcp-auth.ts +120 -2
- package/node_modules/pi-mcp-adapter/mcp-code.ts +13 -11
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +19 -13
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +15 -11
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +34 -15
- package/node_modules/pi-mcp-adapter/mcp-probe.ts +131 -34
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +2 -2
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +7 -4
- package/node_modules/pi-mcp-adapter/mcp-trace.ts +59 -64
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +34 -26
- package/node_modules/pi-mcp-adapter/npx-resolver.ts +6 -4
- package/node_modules/pi-mcp-adapter/oauth-handler.ts +1 -1
- package/node_modules/pi-mcp-adapter/onboarding-state.ts +19 -11
- package/node_modules/pi-mcp-adapter/package.json +13 -8
- package/node_modules/pi-mcp-adapter/panel-keys.ts +20 -4
- package/node_modules/pi-mcp-adapter/prompts.ts +2 -2
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +48 -11
- package/node_modules/pi-mcp-adapter/sampling-handler.ts +22 -15
- package/node_modules/pi-mcp-adapter/search-ranking.ts +2 -1
- package/node_modules/pi-mcp-adapter/server-manager.ts +165 -113
- package/node_modules/pi-mcp-adapter/session-recovery.ts +11 -12
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +3 -3
- package/node_modules/pi-mcp-adapter/state.ts +3 -1
- package/node_modules/pi-mcp-adapter/tool-approval.ts +67 -4
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +6 -5
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +14 -2
- package/node_modules/pi-mcp-adapter/ts-shape.ts +9 -2
- package/node_modules/pi-mcp-adapter/types.ts +109 -22
- package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +40 -0
- package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +28 -19
- package/node_modules/pi-mcp-adapter/ui-server.ts +90 -58
- package/node_modules/pi-mcp-adapter/ui-session.ts +16 -14
- package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +4 -4
- package/node_modules/pi-mcp-adapter/utils.ts +23 -9
- package/package.json +22 -7
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { getAgentPath } from "./agent-dir.ts";
|
|
4
|
+
import type { McpConfig, ServerEntry } from "./types.ts";
|
|
5
|
+
|
|
6
|
+
const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
7
|
+
const MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
|
|
8
|
+
const PLUGIN_NAME_PATTERN = /^(?!.*(?:--|\.\.))[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;
|
|
9
|
+
const PLUGIN_MANIFEST_FIELDS = new Set([
|
|
10
|
+
"$schema",
|
|
11
|
+
"name",
|
|
12
|
+
"version",
|
|
13
|
+
"description",
|
|
14
|
+
"author",
|
|
15
|
+
"homepage",
|
|
16
|
+
"repository",
|
|
17
|
+
"license",
|
|
18
|
+
"keywords",
|
|
19
|
+
"extensions",
|
|
20
|
+
]);
|
|
21
|
+
const MCP_CONFIG_FIELDS = new Set(["$schema", "mcpServers"]);
|
|
22
|
+
const STDIO_FIELDS = new Set(["type", "command", "args", "env", "cwd"]);
|
|
23
|
+
const HTTP_FIELDS = new Set(["type", "url", "headers"]);
|
|
24
|
+
|
|
25
|
+
interface AgentPluginManifest {
|
|
26
|
+
name: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AgentPluginSummary {
|
|
30
|
+
path: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
serverCount: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function loadAgentPluginConfigs(paths: unknown, cwd = process.cwd()): McpConfig {
|
|
36
|
+
const mcpServers: Record<string, ServerEntry> = {};
|
|
37
|
+
for (const pluginPath of getPluginPaths(paths)) {
|
|
38
|
+
const loaded = loadAgentPluginMcpConfig(pluginPath, cwd);
|
|
39
|
+
if (!loaded) continue;
|
|
40
|
+
for (const [serverName, server] of Object.entries(loaded.mcpServers)) {
|
|
41
|
+
if (mcpServers[serverName]) {
|
|
42
|
+
console.warn(`Agent Plugin at ${resolvePluginPath(pluginPath, cwd)} skips duplicate normalized MCP server ${serverName}`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
mcpServers[serverName] = server;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { mcpServers };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getAgentPluginSummaries(paths: unknown, cwd = process.cwd()): AgentPluginSummary[] {
|
|
52
|
+
return getPluginPaths(paths).map(path => {
|
|
53
|
+
const pluginRoot = resolvePluginPath(path, cwd);
|
|
54
|
+
const loaded = loadAgentPluginMcpConfig(path, cwd);
|
|
55
|
+
const manifest = loaded ? readPluginManifest(pluginRoot, false) : null;
|
|
56
|
+
return {
|
|
57
|
+
path: pluginRoot,
|
|
58
|
+
...(manifest?.name ? { name: manifest.name } : {}),
|
|
59
|
+
serverCount: loaded ? Object.keys(loaded.mcpServers).length : 0,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getPluginPaths(paths: unknown): string[] {
|
|
65
|
+
return Array.isArray(paths) ? paths.filter((path): path is string => typeof path === "string") : [];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function loadAgentPluginMcpConfig(path: string, cwd: string): McpConfig | null {
|
|
69
|
+
const pluginRoot = resolvePluginPath(path, cwd);
|
|
70
|
+
const manifest = readPluginManifest(pluginRoot, true);
|
|
71
|
+
if (!manifest) return null;
|
|
72
|
+
|
|
73
|
+
const mcpPath = resolve(pluginRoot, "mcp.json");
|
|
74
|
+
if (!existsSync(mcpPath)) return { mcpServers: {} };
|
|
75
|
+
if (!statSync(mcpPath).isFile()) {
|
|
76
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcp.json is not a regular file`);
|
|
77
|
+
return { mcpServers: {} };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let raw: unknown;
|
|
81
|
+
try {
|
|
82
|
+
raw = JSON.parse(readFileSync(mcpPath, "utf8"));
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: failed to parse mcp.json`, error);
|
|
85
|
+
return { mcpServers: {} };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return translateAgentPluginMcpConfig(raw, manifest, pluginRoot);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function readPluginManifest(pluginRoot: string, report: boolean): AgentPluginManifest | null {
|
|
92
|
+
const manifestPath = resolve(pluginRoot, "plugin.json");
|
|
93
|
+
if (!existsSync(manifestPath)) {
|
|
94
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: missing plugin.json`);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
if (!statSync(manifestPath).isFile()) {
|
|
98
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json is not a regular file`);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let raw: unknown;
|
|
103
|
+
try {
|
|
104
|
+
raw = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: failed to parse plugin.json`, error);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
110
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json must be an object`);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const manifest = raw as Record<string, unknown>;
|
|
115
|
+
for (const key of Object.keys(manifest)) {
|
|
116
|
+
if (!PLUGIN_MANIFEST_FIELDS.has(key) && report) {
|
|
117
|
+
console.warn(`Agent Plugin at ${pluginRoot} ignores unknown plugin.json field: ${key}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (manifest.$schema !== PLUGIN_SCHEMA) {
|
|
121
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: unsupported plugin.json $schema`);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (typeof manifest.name !== "string" || manifest.name.length < 1 || manifest.name.length > 64 || !PLUGIN_NAME_PATTERN.test(manifest.name)) {
|
|
125
|
+
if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json name is invalid`);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (manifest.extensions !== undefined && (!manifest.extensions || typeof manifest.extensions !== "object" || Array.isArray(manifest.extensions))) {
|
|
129
|
+
if (report) console.warn(`Agent Plugin ${manifest.name} ignores non-object plugin.json extensions`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return { name: manifest.name };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function translateAgentPluginMcpConfig(raw: unknown, manifest: AgentPluginManifest, pluginRoot: string): McpConfig {
|
|
136
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
137
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcp.json must be an object`);
|
|
138
|
+
return { mcpServers: {} };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const mcpConfig = raw as Record<string, unknown>;
|
|
142
|
+
for (const key of Object.keys(mcpConfig)) {
|
|
143
|
+
if (!MCP_CONFIG_FIELDS.has(key)) {
|
|
144
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: unknown top-level field ${key}`);
|
|
145
|
+
return { mcpServers: {} };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (mcpConfig.$schema !== MCP_SCHEMA) {
|
|
149
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: unsupported mcp.json $schema`);
|
|
150
|
+
return { mcpServers: {} };
|
|
151
|
+
}
|
|
152
|
+
if (!mcpConfig.mcpServers || typeof mcpConfig.mcpServers !== "object" || Array.isArray(mcpConfig.mcpServers)) {
|
|
153
|
+
console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcpServers must be an object`);
|
|
154
|
+
return { mcpServers: {} };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const mcpServers: Record<string, ServerEntry> = {};
|
|
158
|
+
for (const [serverName, entry] of Object.entries(mcpConfig.mcpServers)) {
|
|
159
|
+
const translated = translateAgentPluginServer(manifest, pluginRoot, serverName, entry);
|
|
160
|
+
if (!translated) continue;
|
|
161
|
+
|
|
162
|
+
const normalizedName = formatAgentPluginServerName(manifest.name, serverName);
|
|
163
|
+
if (mcpServers[normalizedName]) {
|
|
164
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: normalized server name ${normalizedName} already exists`);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
mcpServers[normalizedName] = translated;
|
|
168
|
+
}
|
|
169
|
+
return { mcpServers };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function translateAgentPluginServer(
|
|
173
|
+
manifest: AgentPluginManifest,
|
|
174
|
+
pluginRoot: string,
|
|
175
|
+
serverName: string,
|
|
176
|
+
entry: unknown,
|
|
177
|
+
): ServerEntry | null {
|
|
178
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
179
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: entry must be an object`);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const raw = entry as Record<string, unknown>;
|
|
184
|
+
if (raw.type === "stdio") return translateStdioServer(manifest, pluginRoot, serverName, raw);
|
|
185
|
+
if (raw.type === "streamable-http" || raw.type === "sse") return translateHttpServer(manifest, serverName, raw, raw.type);
|
|
186
|
+
|
|
187
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: unsupported type`);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function translateStdioServer(
|
|
192
|
+
manifest: AgentPluginManifest,
|
|
193
|
+
pluginRoot: string,
|
|
194
|
+
serverName: string,
|
|
195
|
+
raw: Record<string, unknown>,
|
|
196
|
+
): ServerEntry | null {
|
|
197
|
+
for (const key of Object.keys(raw)) {
|
|
198
|
+
if (!STDIO_FIELDS.has(key)) return skipServer(manifest, serverName, `unknown field ${key}`);
|
|
199
|
+
}
|
|
200
|
+
if (typeof raw.command !== "string" || raw.command.length === 0) return skipServer(manifest, serverName, "command must be a non-empty string");
|
|
201
|
+
if (!isBareCommand(raw.command) && !raw.command.startsWith("./")) return skipServer(manifest, serverName, "command must be bare or plugin-relative");
|
|
202
|
+
|
|
203
|
+
const args = translateStringArray(raw.args, manifest, serverName, "args");
|
|
204
|
+
if (args === null) return null;
|
|
205
|
+
const env = translateEnv(raw.env, manifest, serverName);
|
|
206
|
+
if (env === null) return null;
|
|
207
|
+
|
|
208
|
+
const command = raw.command.startsWith("./") ? resolveContainedPath(pluginRoot, raw.command, pluginRoot) : raw.command;
|
|
209
|
+
if (command === null) return skipServer(manifest, serverName, "command must stay inside the plugin directory");
|
|
210
|
+
|
|
211
|
+
const pluginDataDir = getAgentPath("agent-plugin-data", manifest.name);
|
|
212
|
+
const cwd = resolvePluginCwd(raw.cwd, pluginRoot, pluginDataDir);
|
|
213
|
+
if (cwd === null) return skipServer(manifest, serverName, "cwd must be plugin-relative, PLUGIN_ROOT-rooted, or PLUGIN_DATA-rooted");
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
command,
|
|
217
|
+
args: args.map(value => expandPluginPlaceholders(value, pluginRoot, pluginDataDir)),
|
|
218
|
+
env: {
|
|
219
|
+
...Object.fromEntries(Object.entries(env).map(([key, value]) => [key, expandPluginPlaceholders(value, pluginRoot, pluginDataDir)])),
|
|
220
|
+
PLUGIN_ROOT: pluginRoot,
|
|
221
|
+
PLUGIN_DATA: pluginDataDir,
|
|
222
|
+
},
|
|
223
|
+
cwd,
|
|
224
|
+
pluginDataDir,
|
|
225
|
+
literalEnv: true,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function translateHttpServer(
|
|
230
|
+
manifest: AgentPluginManifest,
|
|
231
|
+
serverName: string,
|
|
232
|
+
raw: Record<string, unknown>,
|
|
233
|
+
type: "streamable-http" | "sse",
|
|
234
|
+
): ServerEntry | null {
|
|
235
|
+
for (const key of Object.keys(raw)) {
|
|
236
|
+
if (!HTTP_FIELDS.has(key)) return skipServer(manifest, serverName, `unknown field ${key}`);
|
|
237
|
+
}
|
|
238
|
+
if (typeof raw.url !== "string" || raw.url.length === 0) return skipServer(manifest, serverName, "url must be a non-empty string");
|
|
239
|
+
if (!isValidAgentPluginUrl(raw.url)) return skipServer(manifest, serverName, "url must be an allowed absolute HTTP(S) URL");
|
|
240
|
+
const headers = translateHeaders(raw.headers, manifest, serverName);
|
|
241
|
+
if (headers === null) return null;
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
url: raw.url,
|
|
245
|
+
httpTransport: type,
|
|
246
|
+
...(headers ? { headers } : {}),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function formatAgentPluginServerName(pluginName: string, serverName: string): string {
|
|
251
|
+
const pluginPart = pluginName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "") || "plugin";
|
|
252
|
+
const serverPart = serverName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "") || "server";
|
|
253
|
+
return `${pluginPart}__${serverPart}`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function skipServer(manifest: AgentPluginManifest, serverName: string, reason: string): null {
|
|
257
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: ${reason}`);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function translateStringArray(value: unknown, manifest: AgentPluginManifest, serverName: string, field: string): string[] | null {
|
|
262
|
+
if (value === undefined) return [];
|
|
263
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== "string")) {
|
|
264
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: ${field} must be an array of strings`);
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function translateEnv(value: unknown, manifest: AgentPluginManifest, serverName: string): Record<string, string> | null {
|
|
271
|
+
if (value === undefined) return {};
|
|
272
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
273
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env must be an object of strings`);
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
const env: Record<string, string> = {};
|
|
277
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
278
|
+
if (key === "PLUGIN_ROOT" || key === "PLUGIN_DATA") {
|
|
279
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env must not define ${key}`);
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
if (typeof entry !== "string") {
|
|
283
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env values must be strings`);
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
env[key] = entry;
|
|
287
|
+
}
|
|
288
|
+
return env;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function translateHeaders(value: unknown, manifest: AgentPluginManifest, serverName: string): Record<string, string> | undefined | null {
|
|
292
|
+
if (value === undefined) return undefined;
|
|
293
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
294
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: headers must be an object of strings`);
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
const headers: Record<string, string> = {};
|
|
298
|
+
const seen = new Set<string>();
|
|
299
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
300
|
+
if (typeof entry !== "string") {
|
|
301
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: header values must be strings`);
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
const normalized = key.toLowerCase();
|
|
305
|
+
if (seen.has(normalized)) {
|
|
306
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: duplicate header ${key}`);
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
seen.add(normalized);
|
|
310
|
+
headers[key] = entry;
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
new Headers(headers);
|
|
314
|
+
} catch {
|
|
315
|
+
console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: headers are not valid HTTP fields`);
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
return Object.keys(headers).length > 0 ? headers : undefined;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function resolvePluginPath(path: string, cwd: string): string {
|
|
322
|
+
if (path === "~") return resolve(process.env.HOME ?? "", ".");
|
|
323
|
+
if (path.startsWith("~/")) return resolve(process.env.HOME ?? "", path.slice(2));
|
|
324
|
+
return isAbsolute(path) ? resolve(path) : resolve(cwd, path);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function isBareCommand(command: string): boolean {
|
|
328
|
+
return !command.includes("/") && !command.includes("\\") && !command.includes("${PLUGIN_ROOT}") && !command.includes("${PLUGIN_DATA}");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function resolvePluginCwd(value: unknown, pluginRoot: string, pluginDataDir: string): string | null {
|
|
332
|
+
if (value === undefined) return pluginRoot;
|
|
333
|
+
if (typeof value !== "string") return null;
|
|
334
|
+
if (value.startsWith("./")) return resolveContainedPath(pluginRoot, value, pluginRoot);
|
|
335
|
+
if (value === "${PLUGIN_ROOT}" || value.startsWith("${PLUGIN_ROOT}/")) {
|
|
336
|
+
return resolveContainedPath(pluginRoot, value.replace("${PLUGIN_ROOT}", "."), pluginRoot);
|
|
337
|
+
}
|
|
338
|
+
if (value === "${PLUGIN_DATA}" || value.startsWith("${PLUGIN_DATA}/")) {
|
|
339
|
+
return resolveContainedPath(pluginDataDir, value.replace("${PLUGIN_DATA}", "."), pluginDataDir);
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function resolveContainedPath(root: string, value: string, containmentRoot: string): string | null {
|
|
345
|
+
const resolved = resolve(root, value);
|
|
346
|
+
const rel = relative(containmentRoot, resolved);
|
|
347
|
+
if (rel === "" || (!rel.startsWith("..") && !rel.startsWith(sep) && !isAbsolute(rel))) return resolved;
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDir: string): string {
|
|
352
|
+
return value
|
|
353
|
+
.replaceAll("${PLUGIN_ROOT}", pluginRoot)
|
|
354
|
+
.replaceAll("${PLUGIN_DATA}", pluginDataDir);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function isValidAgentPluginUrl(value: string): boolean {
|
|
358
|
+
if (value.includes("${") || value.includes("$env:") || value.includes("{env:")) return false;
|
|
359
|
+
|
|
360
|
+
let url: URL;
|
|
361
|
+
try {
|
|
362
|
+
url = new URL(value);
|
|
363
|
+
} catch {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return false;
|
|
367
|
+
if (url.username || url.password || url.hash) return false;
|
|
368
|
+
if (url.protocol === "https:") return true;
|
|
369
|
+
return isLoopbackHost(url.hostname);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function isLoopbackHost(hostname: string): boolean {
|
|
373
|
+
const host = hostname.toLowerCase();
|
|
374
|
+
if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]") return true;
|
|
375
|
+
if (/^127(?:\.\d{1,3}){3}$/.test(host)) return true;
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
@@ -4,6 +4,7 @@ import { isServerDisabled, type McpAuthResult, type McpConfig, type McpPanelCall
|
|
|
4
4
|
import {
|
|
5
5
|
ensureCompatibilityImports,
|
|
6
6
|
getMcpDiscoverySummary,
|
|
7
|
+
getMcpStandardConfigSummary,
|
|
7
8
|
getProjectConfigPath,
|
|
8
9
|
type KnownServerPreset,
|
|
9
10
|
getServerProvenance,
|
|
@@ -277,8 +278,8 @@ export async function authenticateServer(
|
|
|
277
278
|
"info"
|
|
278
279
|
);
|
|
279
280
|
},
|
|
280
|
-
signal,
|
|
281
|
-
runtime,
|
|
281
|
+
...(signal ? { signal } : {}),
|
|
282
|
+
...(runtime ? { runtime } : {}),
|
|
282
283
|
});
|
|
283
284
|
if (signal?.aborted) signal.throwIfAborted();
|
|
284
285
|
|
|
@@ -354,7 +355,7 @@ export interface PanelFlowResult {
|
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
function buildSharedConfigNoticeLines(configOverridePath: string | undefined, cwd: string): { lines: string[]; fingerprint: string | null } {
|
|
357
|
-
const discovery =
|
|
358
|
+
const discovery = getMcpStandardConfigSummary(configOverridePath, cwd);
|
|
358
359
|
const onboardingState = loadOnboardingState();
|
|
359
360
|
if (!discovery.hasSharedServers || onboardingState.sharedConfigHintShown) {
|
|
360
361
|
return { lines: [], fingerprint: null };
|
|
@@ -377,6 +378,7 @@ export async function openMcpSetup(
|
|
|
377
378
|
ctx: ExtensionContext,
|
|
378
379
|
configOverridePath?: string,
|
|
379
380
|
mode: "empty" | "setup" = "setup",
|
|
381
|
+
options: { includeHostConfigs?: boolean } = {},
|
|
380
382
|
): Promise<PanelFlowResult> {
|
|
381
383
|
if (!ctx.hasUI) return { configChanged: false };
|
|
382
384
|
if (state.programmaticConfig) {
|
|
@@ -384,7 +386,7 @@ export async function openMcpSetup(
|
|
|
384
386
|
return { configChanged: false };
|
|
385
387
|
}
|
|
386
388
|
|
|
387
|
-
const discovery = getMcpDiscoverySummary(configOverridePath, ctx.cwd);
|
|
389
|
+
const discovery = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options);
|
|
388
390
|
const onboardingState = loadOnboardingState();
|
|
389
391
|
const { createMcpSetupPanel } = await import("./mcp-setup-panel.ts");
|
|
390
392
|
let configChanged = false;
|
|
@@ -393,7 +395,7 @@ export async function openMcpSetup(
|
|
|
393
395
|
previewImports: (imports: ImportKind[]) => previewCompatibilityImports(imports, configOverridePath),
|
|
394
396
|
previewStarterProject: () => previewStarterProjectConfig(ctx.cwd),
|
|
395
397
|
previewRepoPrompt: () => {
|
|
396
|
-
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd).repoPrompt;
|
|
398
|
+
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
397
399
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) return null;
|
|
398
400
|
return previewSharedServerEntry(repoPrompt.targetPath, repoPrompt.serverName, repoPrompt.entry);
|
|
399
401
|
},
|
|
@@ -409,7 +411,7 @@ export async function openMcpSetup(
|
|
|
409
411
|
return { path };
|
|
410
412
|
},
|
|
411
413
|
addRepoPrompt: async () => {
|
|
412
|
-
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd).repoPrompt;
|
|
414
|
+
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
413
415
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) {
|
|
414
416
|
throw new Error("RepoPrompt is not available to add from this setup screen.");
|
|
415
417
|
}
|
|
@@ -514,7 +516,7 @@ export async function openMcpPanel(
|
|
|
514
516
|
return { configChanged: false };
|
|
515
517
|
}
|
|
516
518
|
if (Object.keys(state.config.mcpServers).length === 0) {
|
|
517
|
-
return openMcpSetup(state, pi, ctx, configOverridePath, "empty");
|
|
519
|
+
return openMcpSetup(state, pi, ctx, configOverridePath, "empty", { includeHostConfigs: false });
|
|
518
520
|
}
|
|
519
521
|
|
|
520
522
|
const config = state.config;
|