@jmylchreest/aide-plugin 0.0.34 → 0.0.36
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/package.json +1 -1
- package/src/core/mcp-sync.ts +37 -8
package/package.json
CHANGED
package/src/core/mcp-sync.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* back to the current assistant's config files.
|
|
7
7
|
*
|
|
8
8
|
* Supports:
|
|
9
|
-
* - Claude Code: ~/.
|
|
9
|
+
* - Claude Code: ~/.claude.json (user), .mcp.json (project) (reads legacy ~/.mcp.json)
|
|
10
10
|
* - OpenCode: ~/.config/opencode/opencode.json (user), ./opencode.json (project)
|
|
11
11
|
* - Aide canonical: ~/.aide/config/mcp.json (user), .aide/config/mcp.json (project)
|
|
12
12
|
*
|
|
@@ -43,6 +43,8 @@ export interface CanonicalMcpServer {
|
|
|
43
43
|
name: string;
|
|
44
44
|
/** "local" (stdio) or "remote" (http/sse) */
|
|
45
45
|
type: "local" | "remote";
|
|
46
|
+
/** Remote transport (http/sse) */
|
|
47
|
+
transport?: "http" | "sse";
|
|
46
48
|
/** Command to run (for local servers) */
|
|
47
49
|
command?: string;
|
|
48
50
|
/** Arguments (for local servers) */
|
|
@@ -108,14 +110,32 @@ function userJournalPath(): string {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/** Get all config file paths for a given assistant and scope. */
|
|
111
|
-
function
|
|
113
|
+
function getAssistantReadPaths(
|
|
112
114
|
platform: McpPlatform,
|
|
113
115
|
scope: McpScope,
|
|
114
116
|
cwd: string,
|
|
115
117
|
): string[] {
|
|
116
118
|
if (platform === "claude-code") {
|
|
117
119
|
return scope === "user"
|
|
118
|
-
? [join(homedir(), ".mcp.json")]
|
|
120
|
+
? [join(homedir(), ".claude.json"), join(homedir(), ".mcp.json")]
|
|
121
|
+
: [join(cwd, ".mcp.json")];
|
|
122
|
+
}
|
|
123
|
+
if (platform === "opencode") {
|
|
124
|
+
return scope === "user"
|
|
125
|
+
? [join(homedir(), ".config", "opencode", "opencode.json")]
|
|
126
|
+
: [join(cwd, "opencode.json")];
|
|
127
|
+
}
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function getAssistantWritePaths(
|
|
132
|
+
platform: McpPlatform,
|
|
133
|
+
scope: McpScope,
|
|
134
|
+
cwd: string,
|
|
135
|
+
): string[] {
|
|
136
|
+
if (platform === "claude-code") {
|
|
137
|
+
return scope === "user"
|
|
138
|
+
? [join(homedir(), ".claude.json")]
|
|
119
139
|
: [join(cwd, ".mcp.json")];
|
|
120
140
|
}
|
|
121
141
|
if (platform === "opencode") {
|
|
@@ -177,12 +197,20 @@ function readClaudeConfig(path: string): Record<string, CanonicalMcpServer> {
|
|
|
177
197
|
for (const [name, def] of Object.entries(
|
|
178
198
|
(raw.mcpServers || {}) as Record<string, Record<string, unknown>>,
|
|
179
199
|
)) {
|
|
180
|
-
const claudeType =
|
|
181
|
-
|
|
200
|
+
const claudeType =
|
|
201
|
+
(def.type as string) ||
|
|
202
|
+
((def.url as string | undefined) ? "http" : "stdio");
|
|
203
|
+
const isRemote =
|
|
204
|
+
claudeType === "sse" || claudeType === "http" || !!def.url;
|
|
182
205
|
|
|
183
206
|
servers[name] = {
|
|
184
207
|
name,
|
|
185
208
|
type: isRemote ? "remote" : "local",
|
|
209
|
+
transport: isRemote
|
|
210
|
+
? claudeType === "sse"
|
|
211
|
+
? "sse"
|
|
212
|
+
: "http"
|
|
213
|
+
: undefined,
|
|
186
214
|
command: def.command as string | undefined,
|
|
187
215
|
args: def.args as string[] | undefined,
|
|
188
216
|
url: def.url as string | undefined,
|
|
@@ -236,6 +264,7 @@ function readOpenCodeConfig(path: string): Record<string, CanonicalMcpServer> {
|
|
|
236
264
|
servers[name] = {
|
|
237
265
|
name,
|
|
238
266
|
type: isRemote ? "remote" : "local",
|
|
267
|
+
transport: isRemote ? "http" : undefined,
|
|
239
268
|
command,
|
|
240
269
|
args: args?.length ? args : undefined,
|
|
241
270
|
url: def.url as string | undefined,
|
|
@@ -315,7 +344,7 @@ function writeClaudeConfig(
|
|
|
315
344
|
const entry: Record<string, unknown> = {};
|
|
316
345
|
|
|
317
346
|
if (server.type === "remote") {
|
|
318
|
-
entry.type = "sse";
|
|
347
|
+
entry.type = server.transport === "sse" ? "sse" : "http";
|
|
319
348
|
if (server.url) entry.url = server.url;
|
|
320
349
|
if (server.headers) entry.headers = server.headers;
|
|
321
350
|
} else {
|
|
@@ -536,7 +565,7 @@ function collectServers(
|
|
|
536
565
|
|
|
537
566
|
// Assistant configs
|
|
538
567
|
for (const platform of platforms) {
|
|
539
|
-
const paths =
|
|
568
|
+
const paths = getAssistantReadPaths(platform, scope, cwd);
|
|
540
569
|
for (const p of paths) {
|
|
541
570
|
const servers = readAssistantConfig(platform, p);
|
|
542
571
|
if (Object.keys(servers).length > 0) {
|
|
@@ -630,7 +659,7 @@ function syncScope(
|
|
|
630
659
|
}
|
|
631
660
|
|
|
632
661
|
// Step 7: Write to current assistant's config
|
|
633
|
-
const assistantPaths =
|
|
662
|
+
const assistantPaths = getAssistantWritePaths(platform, scope, cwd);
|
|
634
663
|
for (const p of assistantPaths) {
|
|
635
664
|
// Read existing assistant config to check if it needs updating
|
|
636
665
|
const existingAssistant = readAssistantConfig(platform, p);
|