@sveltejs/opencode 0.0.1 → 0.0.3
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 +75 -0
- package/config.ts +20 -16
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @sveltejs/opencode
|
|
2
|
+
|
|
3
|
+
OpenCode plugin for Svelte that provides the Svelte MCP server, a specialized file editor subagent and instruction files.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add `@sveltejs/opencode` to your OpenCode config (either global or local):
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"$schema": "https://opencode.ai/config.json",
|
|
12
|
+
"plugin": ["@sveltejs/opencode"]
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
That's it! You now have the Svelte MCP server and the file editor subagent configured automatically.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
### Svelte MCP Server
|
|
21
|
+
|
|
22
|
+
The plugin automatically configures the [Svelte MCP server](https://mcp.svelte.dev) which provides:
|
|
23
|
+
|
|
24
|
+
- **list-sections** - Discover available Svelte 5 and SvelteKit documentation sections
|
|
25
|
+
- **get-documentation** - Retrieve full documentation content for specific sections
|
|
26
|
+
- **svelte-autofixer** - Analyze Svelte code and get issues/suggestions
|
|
27
|
+
- **playground-link** - Generate Svelte Playground links with provided code
|
|
28
|
+
|
|
29
|
+
### Svelte File Editor Subagent
|
|
30
|
+
|
|
31
|
+
A specialized subagent (`svelte-file-editor`) that is automatically used when creating, editing, or reviewing `.svelte`, `.svelte.ts`, or `.svelte.js` files. It fetches relevant documentation and validates code using the Svelte MCP server tools.
|
|
32
|
+
|
|
33
|
+
### Agent Instructions
|
|
34
|
+
|
|
35
|
+
The plugin injects instructions that teach the agent how to effectively use the Svelte MCP tools.
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
The default configuration:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"$schema": "https://raw.githubusercontent.com/sveltejs/mcp/refs/heads/main/packages/opencode/schema.json",
|
|
44
|
+
"mcp": {
|
|
45
|
+
"type": "remote",
|
|
46
|
+
"enabled": true
|
|
47
|
+
},
|
|
48
|
+
"subagent": {
|
|
49
|
+
"enabled": true
|
|
50
|
+
},
|
|
51
|
+
"instructions": {
|
|
52
|
+
"enabled": true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Configuration Options
|
|
58
|
+
|
|
59
|
+
| Option | Type | Default | Description |
|
|
60
|
+
| ---------------------- | ----------------------- | ---------- | -------------------------------------------------------------------------------- |
|
|
61
|
+
| `mcp.type` | `"remote"` \| `"local"` | `"remote"` | Use the remote server at `mcp.svelte.dev` or run locally via `npx @sveltejs/mcp` |
|
|
62
|
+
| `mcp.enabled` | `boolean` | `true` | Enable/disable the MCP server |
|
|
63
|
+
| `subagent.enabled` | `boolean` | `true` | Enable/disable the Svelte file editor subagent |
|
|
64
|
+
| `instructions.enabled` | `boolean` | `true` | Enable/disable agent instructions injection |
|
|
65
|
+
|
|
66
|
+
### Config File Location
|
|
67
|
+
|
|
68
|
+
Place your configuration at one of these locations:
|
|
69
|
+
|
|
70
|
+
- `~/.config/opencode/svelte.json` (global)
|
|
71
|
+
- `$OPENCODE_CONFIG_DIR/svelte.json` (if `OPENCODE_CONFIG_DIR` is set, takes priority)
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
package/config.ts
CHANGED
|
@@ -113,28 +113,32 @@ export function get_mcp_config(ctx: PluginInput) {
|
|
|
113
113
|
if (path && existsSync(path)) {
|
|
114
114
|
const result = load_config_file(path);
|
|
115
115
|
if (result.parse_error) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
ctx.client.tui.showToast({
|
|
118
|
+
body: {
|
|
119
|
+
title: 'Svelte: Invalid opencode plugin config',
|
|
120
|
+
message: `${result.parse_error}\nUsing default values`,
|
|
121
|
+
variant: 'warning',
|
|
122
|
+
duration: 7000,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}, 7000);
|
|
124
126
|
return default_config;
|
|
125
127
|
}
|
|
126
128
|
const parsed = v.safeParse(config_schema, result.data);
|
|
127
129
|
if (parsed.success) {
|
|
128
130
|
return merge_with_defaults(parsed.output);
|
|
129
131
|
} else {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
ctx.client.tui.showToast({
|
|
134
|
+
body: {
|
|
135
|
+
title: 'Svelte: Invalid opencode plugin config',
|
|
136
|
+
message: `${result.parse_error}\nUsing default values`,
|
|
137
|
+
variant: 'warning',
|
|
138
|
+
duration: 7000,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}, 7000);
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
}
|