@sveltejs/opencode 0.0.2 → 0.1.0

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 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
@@ -15,6 +15,9 @@ const default_config = {
15
15
  instructions: {
16
16
  enabled: true,
17
17
  },
18
+ skills: {
19
+ enabled: true,
20
+ },
18
21
  };
19
22
 
20
23
  export const config_schema = v.object({
@@ -34,6 +37,11 @@ export const config_schema = v.object({
34
37
  enabled: v.optional(v.boolean()),
35
38
  }),
36
39
  ),
40
+ skills: v.optional(
41
+ v.object({
42
+ enabled: v.optional(v.boolean()),
43
+ }),
44
+ ),
37
45
  });
38
46
 
39
47
  export type McpConfig = v.InferInput<typeof config_schema>;
@@ -104,6 +112,10 @@ function merge_with_defaults(user_config: Partial<McpConfig>): McpConfig {
104
112
  ...default_config.instructions,
105
113
  ...user_config.instructions,
106
114
  },
115
+ skills: {
116
+ ...default_config.skills,
117
+ ...user_config.skills,
118
+ },
107
119
  };
108
120
  }
109
121
 
package/index.ts CHANGED
@@ -12,6 +12,8 @@ export const svelte_plugin: Plugin = async (ctx) => {
12
12
  input.agent ??= {};
13
13
  input.mcp ??= {};
14
14
  input.instructions ??= [];
15
+ // @ts-expect-error -- types are wrong in the opencode package...will fix there and remove this
16
+ input.skills ??= [];
15
17
  // by default we use svelte as the name for the svelte MCP server
16
18
  let svelte_mcp_name = 'svelte';
17
19
  // we loop over every mcp server to see if any of them is already the svelte MCP server
@@ -35,6 +37,12 @@ export const svelte_plugin: Plugin = async (ctx) => {
35
37
  input.instructions.push(...instructions_paths.map((file) => join(instructions_dir, file)));
36
38
  }
37
39
 
40
+ if (mcp_config.skills?.enabled !== false) {
41
+ const skills_dir = join(current_dir, 'skills');
42
+ // @ts-expect-error -- skills is a new opencode feature
43
+ input.skills.push(skills_dir);
44
+ }
45
+
38
46
  // if the user doesn't have the MCP server already we add one based on config
39
47
  if (!input.mcp[svelte_mcp_name] && mcp_config.mcp?.enabled !== false) {
40
48
  if (mcp_config.mcp?.type === 'remote') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/opencode",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sveltejs/mcp#readme",
@@ -10,7 +10,8 @@
10
10
  "files": [
11
11
  "index.ts",
12
12
  "config.ts",
13
- "instructions"
13
+ "instructions",
14
+ "skills"
14
15
  ],
15
16
  "repository": {
16
17
  "type": "git",
@@ -24,7 +25,7 @@
24
25
  "valibot": "^1.2.0"
25
26
  },
26
27
  "devDependencies": {
27
- "@opencode-ai/plugin": "^1.1.21",
28
+ "@opencode-ai/plugin": "^1.1.44",
28
29
  "@valibot/to-json-schema": "^1.5.0",
29
30
  "@types/node": "^24.3.1"
30
31
  },
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: svelte-code-writer
3
+ description: CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating or editing any Svelte component (.svelte) or Svelte module (.svelte.ts/.svelte.js). If possible, this skill should be executed within the svelte-file-editor agent for optimal results.
4
+ ---
5
+
6
+ # Svelte 5 Code Writer
7
+
8
+ ## CLI Tools
9
+
10
+ You have access to `@sveltejs/mcp` CLI for Svelte-specific assistance. Use these commands via `npx`:
11
+
12
+ ### List Documentation Sections
13
+
14
+ ```bash
15
+ npx @sveltejs/mcp list-sections
16
+ ```
17
+
18
+ Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths.
19
+
20
+ ### Get Documentation
21
+
22
+ ```bash
23
+ npx @sveltejs/mcp get-documentation "<section1>,<section2>,..."
24
+ ```
25
+
26
+ Retrieves full documentation for specified sections. Use after `list-sections` to fetch relevant docs.
27
+
28
+ **Example:**
29
+
30
+ ```bash
31
+ npx @sveltejs/mcp get-documentation "$state,$derived,$effect"
32
+ ```
33
+
34
+ ### Svelte Autofixer
35
+
36
+ ```bash
37
+ npx @sveltejs/mcp svelte-autofixer "<code_or_path>" [options]
38
+ ```
39
+
40
+ Analyzes Svelte code and suggests fixes for common issues.
41
+
42
+ **Options:**
43
+
44
+ - `--async` - Enable async Svelte mode (default: false)
45
+ - `--svelte-version` - Target version: 4 or 5 (default: 5)
46
+
47
+ **Examples:**
48
+
49
+ ```bash
50
+ # Analyze inline code (escape $ as \$)
51
+ npx @sveltejs/mcp svelte-autofixer '<script>let count = \$state(0);</script>'
52
+
53
+ # Analyze a file
54
+ npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte
55
+
56
+ # Target Svelte 4
57
+ npx @sveltejs/mcp svelte-autofixer ./Component.svelte --svelte-version 4
58
+ ```
59
+
60
+ **Important:** When passing code with runes (`$state`, `$derived`, etc.) via the terminal, escape the `$` character as `\$` to prevent shell variable substitution.
61
+
62
+ ## Workflow
63
+
64
+ 1. **Uncertain about syntax?** Run `list-sections` then `get-documentation` for relevant topics
65
+ 2. **Reviewing/debugging?** Run `svelte-autofixer` on the code to detect issues
66
+ 3. **Always validate** - Run `svelte-autofixer` before finalizing any Svelte component