@sveltejs/opencode 0.1.0 → 0.1.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/config.ts +22 -7
- package/index.ts +4 -2
- package/instructions/opencode-agents.md +1 -1
- package/package.json +1 -1
package/config.ts
CHANGED
|
@@ -71,8 +71,15 @@ function get_config_paths() {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
|
|
74
|
+
// Project-local: ./.opencode/svelte.json (cwd)
|
|
75
|
+
let project_path: string | null = null;
|
|
76
|
+
const project_config = join(process.cwd(), '.opencode', 'svelte.json');
|
|
77
|
+
if (existsSync(project_config)) {
|
|
78
|
+
project_path = project_config;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Lowest priority first, highest priority last (project overrides global)
|
|
82
|
+
return [global_path, config_dir_path, project_path];
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
function load_config_file(config_path: string): ConfigLoadResult {
|
|
@@ -121,6 +128,9 @@ function merge_with_defaults(user_config: Partial<McpConfig>): McpConfig {
|
|
|
121
128
|
|
|
122
129
|
export function get_mcp_config(ctx: PluginInput) {
|
|
123
130
|
const config_paths = get_config_paths();
|
|
131
|
+
let merged: Partial<McpConfig> = {};
|
|
132
|
+
|
|
133
|
+
// Iterate from lowest to highest priority, merging as we go
|
|
124
134
|
for (const path of config_paths) {
|
|
125
135
|
if (path && existsSync(path)) {
|
|
126
136
|
const result = load_config_file(path);
|
|
@@ -129,23 +139,28 @@ export function get_mcp_config(ctx: PluginInput) {
|
|
|
129
139
|
ctx.client.tui.showToast({
|
|
130
140
|
body: {
|
|
131
141
|
title: 'Svelte: Invalid opencode plugin config',
|
|
132
|
-
message: `${result.parse_error}\
|
|
142
|
+
message: `${result.parse_error} (${path})\nSkipping this config file`,
|
|
133
143
|
variant: 'warning',
|
|
134
144
|
duration: 7000,
|
|
135
145
|
},
|
|
136
146
|
});
|
|
137
147
|
}, 7000);
|
|
138
|
-
|
|
148
|
+
continue;
|
|
139
149
|
}
|
|
140
150
|
const parsed = v.safeParse(config_schema, result.data);
|
|
141
151
|
if (parsed.success) {
|
|
142
|
-
|
|
152
|
+
merged = {
|
|
153
|
+
mcp: { ...merged.mcp, ...parsed.output.mcp },
|
|
154
|
+
subagent: { ...merged.subagent, ...parsed.output.subagent },
|
|
155
|
+
instructions: { ...merged.instructions, ...parsed.output.instructions },
|
|
156
|
+
skills: { ...merged.skills, ...parsed.output.skills },
|
|
157
|
+
};
|
|
143
158
|
} else {
|
|
144
159
|
setTimeout(() => {
|
|
145
160
|
ctx.client.tui.showToast({
|
|
146
161
|
body: {
|
|
147
162
|
title: 'Svelte: Invalid opencode plugin config',
|
|
148
|
-
message:
|
|
163
|
+
message: `Invalid config schema (${path})\nSkipping this config file`,
|
|
149
164
|
variant: 'warning',
|
|
150
165
|
duration: 7000,
|
|
151
166
|
},
|
|
@@ -155,5 +170,5 @@ export function get_mcp_config(ctx: PluginInput) {
|
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
|
|
158
|
-
return
|
|
173
|
+
return merge_with_defaults(merged);
|
|
159
174
|
}
|
package/index.ts
CHANGED
|
@@ -13,7 +13,9 @@ export const svelte_plugin: Plugin = async (ctx) => {
|
|
|
13
13
|
input.mcp ??= {};
|
|
14
14
|
input.instructions ??= [];
|
|
15
15
|
// @ts-expect-error -- types are wrong in the opencode package...will fix there and remove this
|
|
16
|
-
input.skills ??=
|
|
16
|
+
input.skills ??= {};
|
|
17
|
+
// @ts-expect-error -- types are wrong in the opencode package...will fix there and remove this
|
|
18
|
+
input.skills.paths ??= [];
|
|
17
19
|
// by default we use svelte as the name for the svelte MCP server
|
|
18
20
|
let svelte_mcp_name = 'svelte';
|
|
19
21
|
// we loop over every mcp server to see if any of them is already the svelte MCP server
|
|
@@ -40,7 +42,7 @@ export const svelte_plugin: Plugin = async (ctx) => {
|
|
|
40
42
|
if (mcp_config.skills?.enabled !== false) {
|
|
41
43
|
const skills_dir = join(current_dir, 'skills');
|
|
42
44
|
// @ts-expect-error -- skills is a new opencode feature
|
|
43
|
-
input.skills.push(skills_dir);
|
|
45
|
+
input.skills.paths.push(skills_dir);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
// if the user doesn't have the MCP server already we add one based on config
|