@herbertgao/pi-extensions 2026.9.3 → 2026.9.5
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 +2 -1
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/README.es.md +33 -2
- package/node_modules/@dietrichgebert/ponytail/README.ko.md +33 -2
- package/node_modules/@dietrichgebert/ponytail/README.md +49 -5
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-icon.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-dark.svg +4 -0
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-light.svg +4 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +0 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/cursor-hooks.json +17 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +22 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +27 -2
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +61 -2
- package/node_modules/@dietrichgebert/ponytail/package.json +2 -1
- package/node_modules/@dietrichgebert/ponytail/scripts/cursor-hooks.js +135 -0
- package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +21 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +33 -15
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +16 -11
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +6 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-renderer.ts +88 -19
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +12 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +98 -0
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/economics.ts +4 -4
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/extension.ts +41 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +5 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/events.ts +5 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +3 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +56 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/option-list-view.ts +1 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/tab-bar.ts +1 -2
- package/node_modules/@pi-plugins/fast-mode/README.md +31 -44
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +20914 -30
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +5 -7
- package/node_modules/@tifan/pi-copy-response/README.md +2 -2
- package/node_modules/@tifan/pi-copy-response/package.json +3 -2
- package/node_modules/@tifan/pi-inline-skills/README.md +2 -2
- package/node_modules/@tifan/pi-inline-skills/package.json +3 -2
- package/node_modules/@tifan/pi-mermaid-open/README.md +1 -1
- package/node_modules/@tifan/pi-mermaid-open/package.json +3 -2
- package/node_modules/@tifan/pi-preferred-thinking/package.json +3 -2
- package/node_modules/@tifan/pi-recap/package.json +3 -2
- package/node_modules/pi-antigravity/LICENSE +21 -0
- package/node_modules/pi-antigravity/README.md +194 -0
- package/node_modules/pi-antigravity/package.json +67 -0
- package/node_modules/pi-antigravity/src/auth/index.ts +14 -0
- package/node_modules/pi-antigravity/src/auth/oauth.ts +442 -0
- package/node_modules/pi-antigravity/src/client/client.ts +561 -0
- package/node_modules/pi-antigravity/src/client/index.ts +1 -0
- package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +96 -0
- package/node_modules/pi-antigravity/src/diagnostics/index.ts +1 -0
- package/node_modules/pi-antigravity/src/image/image.ts +336 -0
- package/node_modules/pi-antigravity/src/image/index.ts +1 -0
- package/node_modules/pi-antigravity/src/index.ts +280 -0
- package/node_modules/pi-antigravity/src/models/discovery.ts +154 -0
- package/node_modules/pi-antigravity/src/models/grouping.ts +424 -0
- package/node_modules/pi-antigravity/src/models/index.ts +3 -0
- package/node_modules/pi-antigravity/src/models/models.ts +500 -0
- package/node_modules/pi-antigravity/src/stream/index.ts +1 -0
- package/node_modules/pi-antigravity/src/stream/stream.ts +1460 -0
- package/node_modules/pi-antigravity/src/types/enums.ts +42 -0
- package/node_modules/pi-antigravity/src/types/index.ts +2 -0
- package/node_modules/pi-antigravity/src/types/types.ts +292 -0
- package/node_modules/pi-antigravity/src/usage/index.ts +1 -0
- package/node_modules/pi-antigravity/src/usage/usage.ts +371 -0
- package/node_modules/pi-antigravity/src/utils/http.ts +91 -0
- package/node_modules/pi-antigravity/src/utils/index.ts +3 -0
- package/node_modules/pi-antigravity/src/utils/security.ts +73 -0
- package/node_modules/pi-antigravity/src/utils/util.ts +132 -0
- package/node_modules/pi-antigravity/tsconfig.json +21 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +78 -0
- package/node_modules/pi-mcp-adapter/README.md +125 -19
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +69 -30
- package/node_modules/pi-mcp-adapter/agent-plugin-provenance.ts +36 -0
- package/node_modules/pi-mcp-adapter/claude-plugin-loader.ts +365 -0
- package/node_modules/pi-mcp-adapter/commands.ts +13 -15
- package/node_modules/pi-mcp-adapter/config.ts +198 -30
- package/node_modules/pi-mcp-adapter/consent-manager.ts +40 -9
- package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +250 -0
- package/node_modules/pi-mcp-adapter/direct-tools.ts +9 -228
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js +74 -32
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.d.ts +1 -0
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js +31 -0
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.d.ts +9 -0
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js +362 -0
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.d.ts +3 -1
- package/node_modules/pi-mcp-adapter/dist/config.js +189 -27
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +7 -16
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js +5 -17
- package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +30 -4
- package/node_modules/pi-mcp-adapter/dist/types.js +26 -0
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/utils.d.ts +6 -0
- package/node_modules/pi-mcp-adapter/dist/utils.js +65 -6
- package/node_modules/pi-mcp-adapter/dist/utils.js.map +1 -1
- package/node_modules/pi-mcp-adapter/host-html-template.ts +20 -19
- package/node_modules/pi-mcp-adapter/http-ca.ts +84 -0
- package/node_modules/pi-mcp-adapter/index.ts +827 -164
- package/node_modules/pi-mcp-adapter/init.ts +48 -10
- package/node_modules/pi-mcp-adapter/lazy-loader.ts +7 -0
- package/node_modules/pi-mcp-adapter/mcp-auth-fetch.ts +113 -0
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +256 -77
- package/node_modules/pi-mcp-adapter/mcp-auth.ts +316 -54
- package/node_modules/pi-mcp-adapter/mcp-code.ts +45 -18
- package/node_modules/pi-mcp-adapter/mcp-install.ts +60 -0
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +70 -6
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +53 -42
- package/node_modules/pi-mcp-adapter/mcp-panel-theme.ts +104 -0
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +366 -332
- package/node_modules/pi-mcp-adapter/mcp-references.ts +9 -14
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +3 -1
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +383 -341
- package/node_modules/pi-mcp-adapter/mcp-status.ts +5 -0
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +7 -16
- package/node_modules/pi-mcp-adapter/namespace-tools.ts +61 -3
- package/node_modules/pi-mcp-adapter/oauth.ts +6 -2
- package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +5 -17
- package/node_modules/pi-mcp-adapter/package.json +13 -3
- package/node_modules/pi-mcp-adapter/prompts.ts +35 -3
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +108 -7
- package/node_modules/pi-mcp-adapter/runtime-owner.ts +16 -1
- package/node_modules/pi-mcp-adapter/sampling-handler.ts +9 -32
- package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +20 -93
- package/node_modules/pi-mcp-adapter/server-manager.ts +227 -40
- package/node_modules/pi-mcp-adapter/session-approvals.ts +187 -0
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +9 -1
- package/node_modules/pi-mcp-adapter/state.ts +10 -1
- package/node_modules/pi-mcp-adapter/tool-approval.ts +10 -22
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +14 -0
- package/node_modules/pi-mcp-adapter/types.ts +57 -4
- package/node_modules/pi-mcp-adapter/ui-server.ts +36 -28
- package/node_modules/pi-mcp-adapter/utils.ts +64 -6
- package/package.json +15 -15
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readdirSync, realpathSync, statSync, type Dirent, type Stats } from "node:fs";
|
|
2
|
+
import { basename, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { formatServerNamespace, type ClaudePluginConfig, type McpConfig, type ServerEntry } from "./types.ts";
|
|
4
|
+
import { parseJsonWithComments } from "./utils.ts";
|
|
5
|
+
|
|
6
|
+
interface ClaudePluginManifest {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ClaudePluginBundleResult {
|
|
11
|
+
mcpServers: Record<string, ServerEntry>;
|
|
12
|
+
skillPaths: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function loadClaudePluginBundles(
|
|
16
|
+
plugins: readonly ClaudePluginConfig[] | undefined,
|
|
17
|
+
cwd: string,
|
|
18
|
+
validateConfig: (raw: unknown) => McpConfig,
|
|
19
|
+
components: { mcp: boolean; skills: boolean },
|
|
20
|
+
): ClaudePluginBundleResult {
|
|
21
|
+
const mcpServers: Record<string, ServerEntry> = {};
|
|
22
|
+
const skillPaths: string[] = [];
|
|
23
|
+
const seenRoots = new Set<string>();
|
|
24
|
+
const seenNames = new Map<string, string>();
|
|
25
|
+
const serverSources = new Map<string, string>();
|
|
26
|
+
const normalizedServerNames = new Map<string, string>();
|
|
27
|
+
|
|
28
|
+
for (const plugin of plugins ?? []) {
|
|
29
|
+
const configuredPath = resolvePluginPath(plugin.path, cwd);
|
|
30
|
+
const pluginRoot = resolvePluginRoot(configuredPath);
|
|
31
|
+
if (!pluginRoot) continue;
|
|
32
|
+
if (seenRoots.has(pluginRoot)) {
|
|
33
|
+
console.warn(`Claude plugin path is configured more than once: ${pluginRoot}`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
seenRoots.add(pluginRoot);
|
|
37
|
+
|
|
38
|
+
const manifest = readPluginManifest(pluginRoot);
|
|
39
|
+
if (manifest === false) continue;
|
|
40
|
+
const pluginName = manifest?.name ?? basename(pluginRoot);
|
|
41
|
+
const previousPluginRoot = seenNames.get(pluginName);
|
|
42
|
+
if (previousPluginRoot && previousPluginRoot !== pluginRoot) {
|
|
43
|
+
console.warn(`Claude plugin name conflict for "${pluginName}": ${previousPluginRoot} and ${pluginRoot}`);
|
|
44
|
+
} else {
|
|
45
|
+
seenNames.set(pluginName, pluginRoot);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (components.mcp && plugin.mcp === true) {
|
|
49
|
+
const configPath = resolveContainedComponent(pluginRoot, ".mcp.json", "file", pluginName);
|
|
50
|
+
if (configPath) {
|
|
51
|
+
const config = readPluginMcpConfig(configPath, pluginName, pluginRoot, validateConfig);
|
|
52
|
+
for (const [serverName, server] of Object.entries(config.mcpServers)) {
|
|
53
|
+
const normalizedName = formatServerNamespace(serverName);
|
|
54
|
+
const previousName = normalizedServerNames.get(normalizedName);
|
|
55
|
+
const previousSource = previousName ? serverSources.get(previousName) : undefined;
|
|
56
|
+
if (previousName && previousSource) {
|
|
57
|
+
console.warn(`Claude plugin MCP server name conflict for "${serverName}": normalized name collides with "${previousName}" from ${previousSource}; the first plugin wins over ${configPath}`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
normalizedServerNames.set(normalizedName, serverName);
|
|
61
|
+
serverSources.set(serverName, configPath);
|
|
62
|
+
mcpServers[serverName] = server;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (components.skills && plugin.skills === true) {
|
|
68
|
+
const skillsPath = resolveContainedComponent(pluginRoot, "skills", "directory", pluginName);
|
|
69
|
+
if (skillsPath) {
|
|
70
|
+
try {
|
|
71
|
+
for (const skillPath of discoverContainedSkillFiles(skillsPath, pluginName)) {
|
|
72
|
+
if (!skillPaths.includes(skillPath)) skillPaths.push(skillPath);
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.warn(`Claude plugin "${pluginName}" skills could not be read at ${skillsPath}: ${formatError(error)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { mcpServers, skillPaths };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function resolvePluginPath(path: string, cwd: string): string {
|
|
85
|
+
if (path === "~") return resolve(process.env.HOME ?? "", ".");
|
|
86
|
+
if (path.startsWith("~/")) return resolve(process.env.HOME ?? "", path.slice(2));
|
|
87
|
+
return isAbsolute(path) ? resolve(path) : resolve(cwd, path);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function resolvePluginRoot(path: string): string | null {
|
|
91
|
+
if (!existsSync(path)) {
|
|
92
|
+
console.warn(`Claude plugin path does not exist: ${path}`);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const stats = safeStat(path, "Claude plugin path");
|
|
96
|
+
if (!stats) return null;
|
|
97
|
+
if (!stats.isDirectory()) {
|
|
98
|
+
console.warn(`Claude plugin path is not a directory: ${path}`);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return safeRealpath(path, "Claude plugin path");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function readPluginManifest(pluginRoot: string): ClaudePluginManifest | null | false {
|
|
105
|
+
const configuredManifestPath = resolve(pluginRoot, ".claude-plugin", "plugin.json");
|
|
106
|
+
if (!existsSync(configuredManifestPath)) return null;
|
|
107
|
+
const stats = safeStat(configuredManifestPath, "Claude plugin manifest");
|
|
108
|
+
if (!stats) return null;
|
|
109
|
+
if (!stats.isFile()) {
|
|
110
|
+
console.warn(`Claude plugin manifest is not a regular file: ${configuredManifestPath}`);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const manifestPath = safeRealpath(configuredManifestPath, "Claude plugin manifest");
|
|
114
|
+
if (!manifestPath) return null;
|
|
115
|
+
if (!isContainedPath(pluginRoot, manifestPath)) {
|
|
116
|
+
console.warn(`Claude plugin manifest resolves outside the configured plugin directory: ${manifestPath}`);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const manifestText = safeReadFile(manifestPath, "Claude plugin manifest", pluginRoot);
|
|
121
|
+
if (manifestText === null) return null;
|
|
122
|
+
|
|
123
|
+
let raw: unknown;
|
|
124
|
+
try {
|
|
125
|
+
raw = parseJsonWithComments(manifestText);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn(`Claude plugin manifest contains invalid JSON at ${manifestPath}: ${formatError(error)}`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
131
|
+
console.warn(`Claude plugin manifest must be a JSON object: ${manifestPath}`);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const manifest = raw as Record<string, unknown>;
|
|
136
|
+
if (typeof manifest.name !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(manifest.name)) {
|
|
137
|
+
console.warn(`Claude plugin manifest has an invalid name at ${manifestPath}: expected kebab-case`);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (!hasValidManifestFieldTypes(manifest)) {
|
|
141
|
+
console.warn(`Claude plugin manifest has invalid field types at ${manifestPath}`);
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return { name: manifest.name };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function hasValidManifestFieldTypes(manifest: Record<string, unknown>): boolean {
|
|
148
|
+
for (const field of ["$schema", "displayName", "version", "description", "homepage", "repository", "license"] as const) {
|
|
149
|
+
if (manifest[field] !== undefined && typeof manifest[field] !== "string") return false;
|
|
150
|
+
}
|
|
151
|
+
for (const field of ["commands", "agents", "skills", "hooks", "mcpServers", "lspServers", "outputStyles"] as const) {
|
|
152
|
+
const value = manifest[field];
|
|
153
|
+
if (value !== undefined && typeof value !== "string" && (!Array.isArray(value) || value.some(item => typeof item !== "string"))) return false;
|
|
154
|
+
}
|
|
155
|
+
if (manifest.defaultEnabled !== undefined && typeof manifest.defaultEnabled !== "boolean") return false;
|
|
156
|
+
if (manifest.keywords !== undefined && (!Array.isArray(manifest.keywords) || manifest.keywords.some(value => typeof value !== "string"))) return false;
|
|
157
|
+
if (manifest.author !== undefined) {
|
|
158
|
+
if (!manifest.author || typeof manifest.author !== "object" || Array.isArray(manifest.author)) return false;
|
|
159
|
+
const author = manifest.author as Record<string, unknown>;
|
|
160
|
+
if (typeof author.name !== "string") return false;
|
|
161
|
+
if (author.email !== undefined && typeof author.email !== "string") return false;
|
|
162
|
+
if (author.url !== undefined && typeof author.url !== "string") return false;
|
|
163
|
+
}
|
|
164
|
+
if (manifest.metadata !== undefined && (!manifest.metadata || typeof manifest.metadata !== "object" || Array.isArray(manifest.metadata))) return false;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function resolveContainedComponent(
|
|
169
|
+
pluginRoot: string,
|
|
170
|
+
component: string,
|
|
171
|
+
expected: "file" | "directory",
|
|
172
|
+
pluginName: string,
|
|
173
|
+
): string | null {
|
|
174
|
+
const path = resolve(pluginRoot, component);
|
|
175
|
+
if (!existsSync(path)) {
|
|
176
|
+
console.warn(`Claude plugin "${pluginName}" is missing ${component}: ${path}`);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
const stats = safeStat(path, `Claude plugin "${pluginName}" ${component}`);
|
|
180
|
+
if (!stats) return null;
|
|
181
|
+
if (expected === "file" ? !stats.isFile() : !stats.isDirectory()) {
|
|
182
|
+
console.warn(`Claude plugin "${pluginName}" ${component} is not a ${expected}: ${path}`);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const realPath = safeRealpath(path, `Claude plugin "${pluginName}" ${component}`);
|
|
186
|
+
if (!realPath) return null;
|
|
187
|
+
if (!isContainedPath(pluginRoot, realPath)) {
|
|
188
|
+
console.warn(`Claude plugin "${pluginName}" ${component} resolves outside the configured plugin directory: ${realPath}`);
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
return realPath;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function discoverContainedSkillFiles(skillsRoot: string, pluginName: string): string[] {
|
|
195
|
+
const skillFiles: string[] = [];
|
|
196
|
+
const visitedDirectories = new Set<string>();
|
|
197
|
+
const visit = (directory: string): void => {
|
|
198
|
+
const realDirectory = safeRealpath(directory, `Claude plugin "${pluginName}" skill directory`);
|
|
199
|
+
if (!realDirectory) return;
|
|
200
|
+
if (!isContainedPath(skillsRoot, realDirectory)) {
|
|
201
|
+
console.warn(`Claude plugin "${pluginName}" skill path resolves outside its skills directory: ${directory} -> ${realDirectory}`);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (visitedDirectories.has(realDirectory)) return;
|
|
205
|
+
visitedDirectories.add(realDirectory);
|
|
206
|
+
const entries = safeReadDir(realDirectory, `Claude plugin "${pluginName}" skill directory`);
|
|
207
|
+
if (!entries) return;
|
|
208
|
+
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
209
|
+
const path = resolve(realDirectory, entry.name);
|
|
210
|
+
if (entry.isSymbolicLink()) {
|
|
211
|
+
const target = safeRealpath(path, `Claude plugin "${pluginName}" skill path`);
|
|
212
|
+
if (!target) continue;
|
|
213
|
+
if (!isContainedPath(skillsRoot, target)) {
|
|
214
|
+
console.warn(`Claude plugin "${pluginName}" skill path resolves outside its skills directory: ${path} -> ${target}`);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const targetStats = safeStat(target, `Claude plugin "${pluginName}" skill path`);
|
|
218
|
+
if (!targetStats) continue;
|
|
219
|
+
if (targetStats.isDirectory()) visit(target);
|
|
220
|
+
else if (targetStats.isFile() && entry.name === "SKILL.md") skillFiles.push(target);
|
|
221
|
+
} else if (entry.isDirectory()) {
|
|
222
|
+
visit(path);
|
|
223
|
+
} else if (entry.isFile() && entry.name === "SKILL.md") {
|
|
224
|
+
const realPath = safeRealpath(path, `Claude plugin "${pluginName}" skill path`);
|
|
225
|
+
if (!realPath) continue;
|
|
226
|
+
if (!isContainedPath(skillsRoot, realPath)) {
|
|
227
|
+
console.warn(`Claude plugin "${pluginName}" skill path resolves outside its skills directory: ${path} -> ${realPath}`);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
skillFiles.push(realPath);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
visit(skillsRoot);
|
|
235
|
+
return skillFiles;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function readPluginMcpConfig(
|
|
239
|
+
configPath: string,
|
|
240
|
+
pluginName: string,
|
|
241
|
+
pluginRoot: string,
|
|
242
|
+
validateConfig: (raw: unknown) => McpConfig,
|
|
243
|
+
): McpConfig {
|
|
244
|
+
let raw: unknown;
|
|
245
|
+
try {
|
|
246
|
+
const configText = safeReadFile(configPath, `Claude plugin "${pluginName}" MCP config`, pluginRoot);
|
|
247
|
+
if (configText === null) return { mcpServers: {} };
|
|
248
|
+
raw = parseJsonWithComments(configText);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
console.warn(`Claude plugin "${pluginName}" has invalid MCP config at ${configPath}: ${formatError(error)}`);
|
|
251
|
+
return { mcpServers: {} };
|
|
252
|
+
}
|
|
253
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
254
|
+
console.warn(`Claude plugin "${pluginName}" MCP config must be a JSON object: ${configPath}`);
|
|
255
|
+
return { mcpServers: {} };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const servers = (raw as Record<string, unknown>).mcpServers;
|
|
259
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) {
|
|
260
|
+
console.warn(`Claude plugin "${pluginName}" MCP config must contain an mcpServers object: ${configPath}`);
|
|
261
|
+
return { mcpServers: {} };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const config = validateConfig(raw);
|
|
265
|
+
const validated: Record<string, ServerEntry> = {};
|
|
266
|
+
for (const serverName of Object.keys(servers)) {
|
|
267
|
+
if (serverName.trim().length === 0) {
|
|
268
|
+
console.warn(`Claude plugin "${pluginName}" has an empty MCP server name at ${configPath}`);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const parsed = config.mcpServers[serverName];
|
|
272
|
+
if (!parsed || !hasValidServerTransport(parsed)) {
|
|
273
|
+
console.warn(`Claude plugin "${pluginName}" has invalid MCP server "${serverName}" at ${configPath}: expected exactly one non-empty command, url, or socket transport`);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
validated[serverName] = replacePluginRoot(parsed, pluginRoot);
|
|
277
|
+
}
|
|
278
|
+
return { mcpServers: validated };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function hasValidServerTransport(entry: ServerEntry): boolean {
|
|
282
|
+
return [entry.command, entry.url, entry.socket].filter(value => typeof value === "string" && value.trim().length > 0).length === 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function replacePluginRoot(entry: ServerEntry, pluginRoot: string): ServerEntry {
|
|
286
|
+
const replace = (value: string): string => value.replaceAll("${CLAUDE_PLUGIN_ROOT}", pluginRoot);
|
|
287
|
+
const replaced = replaceStrings(entry, replace) as ServerEntry;
|
|
288
|
+
if (typeof replaced.command === "string") {
|
|
289
|
+
replaced.env = { ...replaced.env, CLAUDE_PLUGIN_ROOT: pluginRoot };
|
|
290
|
+
}
|
|
291
|
+
return replaced;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function replaceStrings(value: unknown, replace: (value: string) => string): unknown {
|
|
295
|
+
if (typeof value === "string") return replace(value);
|
|
296
|
+
if (Array.isArray(value)) return value.map(item => replaceStrings(item, replace));
|
|
297
|
+
if (!value || typeof value !== "object") return value;
|
|
298
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, replaceStrings(entry, replace)]));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function isContainedPath(root: string, path: string): boolean {
|
|
302
|
+
const rel = relative(root, path);
|
|
303
|
+
return rel === "" || (!rel.startsWith("..") && !rel.startsWith(sep) && !isAbsolute(rel));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function safeStat(path: string, description: string): Stats | null {
|
|
307
|
+
try {
|
|
308
|
+
return statSync(path);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.warn(`${description} could not be read: ${path}: ${formatError(error)}`);
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function safeRealpath(path: string, description: string): string | null {
|
|
316
|
+
try {
|
|
317
|
+
return realpathSync(path);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.warn(`${description} could not be read: ${path}: ${formatError(error)}`);
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function safeReadFile(path: string, description: string, containmentRoot: string): string | null {
|
|
325
|
+
let fd: number | undefined;
|
|
326
|
+
try {
|
|
327
|
+
fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
328
|
+
const openedStats = fstatSync(fd);
|
|
329
|
+
if (!openedStats.isFile()) {
|
|
330
|
+
console.warn(`${description} is not a regular file: ${path}`);
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
const resolvedPath = safeRealpath(path, description);
|
|
334
|
+
if (!resolvedPath) return null;
|
|
335
|
+
if (!isContainedPath(containmentRoot, resolvedPath)) {
|
|
336
|
+
console.warn(`${description} resolves outside the configured plugin directory: ${resolvedPath}`);
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
const currentStats = safeStat(resolvedPath, description);
|
|
340
|
+
if (!currentStats) return null;
|
|
341
|
+
if (openedStats.dev !== currentStats.dev || openedStats.ino !== currentStats.ino) {
|
|
342
|
+
console.warn(`${description} changed while being read: ${path}`);
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
return readFileSync(fd, "utf8");
|
|
346
|
+
} catch (error) {
|
|
347
|
+
console.warn(`${description} could not be read: ${path}: ${formatError(error)}`);
|
|
348
|
+
return null;
|
|
349
|
+
} finally {
|
|
350
|
+
if (fd !== undefined) closeSync(fd);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function safeReadDir(path: string, description: string): Dirent[] | null {
|
|
355
|
+
try {
|
|
356
|
+
return readdirSync(path, { withFileTypes: true });
|
|
357
|
+
} catch (error) {
|
|
358
|
+
console.warn(`${description} could not be read: ${path}: ${formatError(error)}`);
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function formatError(error: unknown): string {
|
|
364
|
+
return error instanceof Error ? error.message : String(error);
|
|
365
|
+
}
|
|
@@ -311,9 +311,9 @@ export async function authenticateServer(
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
ui.setStatus("mcp-auth", `Authenticating ${serverName}...`);
|
|
314
|
-
const authStorageOptions = getAuthStorageOptions(config.settings?.oauthDir, cwd);
|
|
314
|
+
const authStorageOptions = getAuthStorageOptions(config.settings?.oauthDir, cwd, config.settings?.oauthCredentialStore);
|
|
315
315
|
const status = await authenticate(serverName, serverUrl, definition, {
|
|
316
|
-
...(authStorageOptions.
|
|
316
|
+
...(Object.keys(authStorageOptions).length > 0 ? { authStorageOptions } : {}),
|
|
317
317
|
onAuthorizationUrl: () => {},
|
|
318
318
|
onAuthorizationInput: async (authorizationUrl, inputSignal) => {
|
|
319
319
|
if (inputSignal.aborted) return undefined;
|
|
@@ -364,27 +364,24 @@ export async function logoutServer(
|
|
|
364
364
|
|
|
365
365
|
const signal = state.owner?.signal;
|
|
366
366
|
try {
|
|
367
|
-
await
|
|
367
|
+
await state.manager.close(serverName);
|
|
368
368
|
} catch (error) {
|
|
369
369
|
if (isAbortError(error, signal)) throw error;
|
|
370
370
|
const message = error instanceof Error ? error.message : String(error);
|
|
371
371
|
if (ui) {
|
|
372
|
-
ui.notify(`Failed to
|
|
372
|
+
ui.notify(`Failed to close OAuth server "${serverName}"; credentials were not cleared: ${sanitizeTerminalText(message)}`, "error");
|
|
373
373
|
}
|
|
374
374
|
return { ok: false, message };
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
state.owner?.throwIfInactive();
|
|
378
378
|
try {
|
|
379
|
-
await state.
|
|
379
|
+
await removeAuth(serverName, { authStorageOptions: state.authStorageOptions, signal, runtime: state.oauthRuntime });
|
|
380
380
|
} catch (error) {
|
|
381
381
|
if (isAbortError(error, signal)) throw error;
|
|
382
382
|
const message = error instanceof Error ? error.message : String(error);
|
|
383
383
|
if (ui) {
|
|
384
|
-
ui.notify(
|
|
385
|
-
`OAuth credentials were cleared for "${serverName}", but its connection could not be closed: ${sanitizeTerminalText(message)}`,
|
|
386
|
-
"error",
|
|
387
|
-
);
|
|
384
|
+
ui.notify(`Failed to clear OAuth credentials for "${serverName}": ${sanitizeTerminalText(message)}`, "error");
|
|
388
385
|
}
|
|
389
386
|
return { ok: false, message };
|
|
390
387
|
}
|
|
@@ -474,7 +471,7 @@ function buildSharedConfigNoticeLines(configOverridePath: string | undefined, cw
|
|
|
474
471
|
const discovery = getMcpStandardConfigSummary(configOverridePath, cwd);
|
|
475
472
|
const onboardingState = loadOnboardingState();
|
|
476
473
|
const sharedSources = discovery.sources.filter((source) =>
|
|
477
|
-
(source.id === "shared-project" || source.id === "shared-global") && source.serverCount > 0,
|
|
474
|
+
(source.id === "shared-project" || source.id === "shared-project-ancestor" || source.id === "shared-global") && source.serverCount > 0,
|
|
478
475
|
);
|
|
479
476
|
if (sharedSources.length === 0 || onboardingState.sharedConfigHintShown) {
|
|
480
477
|
return { lines: [], fingerprint: null };
|
|
@@ -556,8 +553,8 @@ export async function openMcpSetup(
|
|
|
556
553
|
|
|
557
554
|
return new Promise<PanelFlowResult>((resolve) => {
|
|
558
555
|
ctx.ui.custom(
|
|
559
|
-
(tui,
|
|
560
|
-
return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
|
|
556
|
+
(tui, theme, keybindings, done) => {
|
|
557
|
+
return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings, theme }, tui, () => {
|
|
561
558
|
done(undefined);
|
|
562
559
|
resolve({ configChanged });
|
|
563
560
|
});
|
|
@@ -670,7 +667,7 @@ export async function openMcpPanel(
|
|
|
670
667
|
|
|
671
668
|
await new Promise<void>((resolve) => {
|
|
672
669
|
ctx.ui.custom(
|
|
673
|
-
(tui,
|
|
670
|
+
(tui, theme, keybindings, done) => {
|
|
674
671
|
return createMcpPanel(config, cache, provenanceMap, callbacks, tui, (result: McpPanelResult) => {
|
|
675
672
|
void (async () => {
|
|
676
673
|
if (!result.cancelled && result.disabledChanges.size > 0) {
|
|
@@ -699,7 +696,7 @@ export async function openMcpPanel(
|
|
|
699
696
|
done(undefined);
|
|
700
697
|
resolve();
|
|
701
698
|
});
|
|
702
|
-
}, { noticeLines, keybindings });
|
|
699
|
+
}, { noticeLines, keybindings, theme });
|
|
703
700
|
},
|
|
704
701
|
{
|
|
705
702
|
overlay: true,
|
|
@@ -750,13 +747,14 @@ export async function openMcpAuthPanel(
|
|
|
750
747
|
|
|
751
748
|
await new Promise<void>((resolve) => {
|
|
752
749
|
ctx.ui.custom(
|
|
753
|
-
(tui,
|
|
750
|
+
(tui, theme, keybindings, done) => {
|
|
754
751
|
return createMcpPanel(config, cache, provenanceMap, callbacks, tui, () => {
|
|
755
752
|
done(undefined);
|
|
756
753
|
resolve();
|
|
757
754
|
}, {
|
|
758
755
|
authOnly: true,
|
|
759
756
|
keybindings,
|
|
757
|
+
theme,
|
|
760
758
|
noticeLines: ["Select an OAuth MCP server and press Enter or ctrl+a to authenticate."],
|
|
761
759
|
});
|
|
762
760
|
},
|