@sveltejs/opencode 0.1.1 → 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/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
|
}
|