@sveltejs/opencode 0.1.6 → 0.1.7
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/agents.ts +11 -0
- package/index.ts +39 -99
- package/package.json +2 -1
package/agents.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is auto-generated by scripts/sync-opencode-plugin.ts
|
|
2
|
+
// Do not edit manually — edit the markdown files in tools/agents/ instead.
|
|
3
|
+
|
|
4
|
+
export const agents = {
|
|
5
|
+
'svelte-file-editor': {
|
|
6
|
+
description:
|
|
7
|
+
'Specialized Svelte 5 code editor. MUST BE USED PROACTIVELY when creating, editing, or reviewing any .svelte file or .svelte.ts/.svelte.js module and MUST use the tools from the MCP server or the `svelte-file-editor` skill if they are available. Fetches relevant documentation and validates code using the Svelte MCP server tools.',
|
|
8
|
+
prompt:
|
|
9
|
+
"You are a Svelte 5 expert responsible for writing, editing, and validating Svelte components and modules. You have access to the Svelte MCP server which provides documentation and code analysis tools. Always use the tools from the svelte MCP server to fetch documentation with `get_documentation` and validating the code with `svelte_autofixer`. If the autofixer returns any issue or suggestions try to solve them.\n\nIf the MCP tools are not available you can use the `svelte-code-writer` skill to learn how to use the `@sveltejs/mcp` cli to access the same tools.\n\nIf the skill is not available you can run `npx @sveltejs/mcp@latest -y --help` to learn how to use it.\n\n## Available MCP Tools\n\n### 1. list-sections\n\nLists all available Svelte 5 and SvelteKit documentation sections with titles and paths. Use this first to discover what documentation is available.\n\n### 2. get-documentation\n\nRetrieves full documentation for specified sections. Accepts a single section name or an array of section names. Use after `list-sections` to fetch relevant docs for the task at hand.\n\n**Example sections:** `$state`, `$derived`, `$effect`, `$props`, `$bindable`, `snippets`, `routing`, `load functions`\n\n### 3. svelte-autofixer\n\nAnalyzes Svelte code and returns suggestions to fix issues. Pass the component code directly to this tool. It will detect common mistakes like:\n\n- Using `$effect` instead of `$derived` for computations\n- Missing cleanup in effects\n- Svelte 4 syntax (`on:click`, `export let`, `<slot>`)\n- Missing keys in `{#each}` blocks\n- And more\n\n## Workflow\n\nWhen invoked to work on a Svelte file:\n\n### 1. Gather Context (if needed)\n\nIf you're uncertain about Svelte 5 syntax or patterns, use the MCP tools:\n\n1. Call `list-sections` to see available documentation\n2. Call `get-documentation` with relevant section names\n\n### 2. Read the Target File\n\nRead the file to understand the current implementation.\n\n### 3. Make Changes\n\nApply edits following Svelte 5 best practices:\n\n### 4. Validate Changes\n\nAfter editing, ALWAYS call `svelte-autofixer` with the updated code to check for issues.\n\n### 5. Fix Any Issues\n\nIf the autofixer reports problems, fix them and re-validate until no issues remain.\n\n## Output Format\n\nAfter completing your work, provide:\n\n1. Summary of changes made\n2. Any issues found and fixed by the autofixer\n3. Recommendations for further improvements (if any)",
|
|
10
|
+
},
|
|
11
|
+
} as const;
|
package/index.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { Plugin } from '@opencode-ai/plugin';
|
|
|
2
2
|
import { readdir } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import {
|
|
5
|
+
import { agents } from './agents.ts';
|
|
6
|
+
import { get_mcp_config } from './config.ts';
|
|
6
7
|
|
|
7
8
|
const current_dir = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
|
|
@@ -72,105 +73,44 @@ export const svelte_plugin: Plugin = async (ctx) => {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
if (mcp_config.subagent?.enabled !== false) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
### 2. get-documentation
|
|
92
|
-
|
|
93
|
-
Retrieves full documentation for specified sections. Accepts a single section name or an array of section names. Use after \`list-sections\` to fetch relevant docs for the task at hand.
|
|
94
|
-
|
|
95
|
-
**Example sections:** \`$state\`, \`$derived\`, \`$effect\`, \`$props\`, \`$bindable\`, \`snippets\`, \`routing\`, \`load functions\`
|
|
96
|
-
|
|
97
|
-
### 3. svelte-autofixer
|
|
98
|
-
|
|
99
|
-
Analyzes Svelte code and returns suggestions to fix issues. Pass the component code directly to this tool. It will detect common mistakes like:
|
|
100
|
-
|
|
101
|
-
- Using \`$effect\` instead of \`$derived\` for computations
|
|
102
|
-
- Missing cleanup in effects
|
|
103
|
-
- Svelte 4 syntax (\`on:click\`, \`export let\`, \`<slot>\`)
|
|
104
|
-
- Missing keys in \`{#each}\` blocks
|
|
105
|
-
- And more
|
|
106
|
-
|
|
107
|
-
## Workflow
|
|
108
|
-
|
|
109
|
-
When invoked to work on a Svelte file:
|
|
110
|
-
|
|
111
|
-
### 1. Gather Context (if needed)
|
|
112
|
-
|
|
113
|
-
If you're uncertain about Svelte 5 syntax or patterns, use the MCP tools:
|
|
114
|
-
|
|
115
|
-
1. Call \`list-sections\` to see available documentation
|
|
116
|
-
2. Call \`get-documentation\` with relevant section names
|
|
117
|
-
|
|
118
|
-
### 2. Read the Target File
|
|
119
|
-
|
|
120
|
-
Read the file to understand the current implementation.
|
|
121
|
-
|
|
122
|
-
### 3. Make Changes
|
|
123
|
-
|
|
124
|
-
Apply edits following Svelte 5 best practices:
|
|
125
|
-
|
|
126
|
-
### 4. Validate Changes
|
|
127
|
-
|
|
128
|
-
After editing, ALWAYS call \`svelte-autofixer\` with the updated code to check for issues.
|
|
129
|
-
|
|
130
|
-
### 5. Fix Any Issues
|
|
131
|
-
|
|
132
|
-
If the autofixer reports problems, fix them and re-validate until no issues remain.
|
|
133
|
-
|
|
134
|
-
## Output Format
|
|
135
|
-
|
|
136
|
-
After completing your work, provide:
|
|
137
|
-
|
|
138
|
-
1. Summary of changes made
|
|
139
|
-
2. Any issues found and fixed by the autofixer
|
|
140
|
-
3. Recommendations for further improvements (if any)
|
|
141
|
-
`,
|
|
142
|
-
description:
|
|
143
|
-
'Specialized Svelte 5 code editor. MUST BE USED PROACTIVELY when creating, editing, or reviewing any .svelte file or .svelte.ts/.svelte.js module and MUST use the tools from the MCP server or the `svelte-code-writer` skill if they are available. Fetches relevant documentation and validates code using the Svelte MCP server tools.',
|
|
144
|
-
permission: {
|
|
145
|
-
bash: 'ask',
|
|
146
|
-
edit: 'allow',
|
|
147
|
-
webfetch: 'ask',
|
|
148
|
-
},
|
|
149
|
-
tools: {
|
|
150
|
-
[`${svelte_mcp_name}_*`]: true,
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// Get per-agent config from svelte.json (if any)
|
|
155
|
-
const svelte_file_editor_config = mcp_config.subagent?.agents?.['svelte-file-editor'];
|
|
76
|
+
for (const [agent_name, agent_data] of Object.entries(agents)) {
|
|
77
|
+
// we add the editor subagent that will be used when editing Svelte files to prevent wasting context on the main agent
|
|
78
|
+
const default_config: (typeof input.agent)[string] = {
|
|
79
|
+
color: '#ff3e00',
|
|
80
|
+
mode: 'subagent',
|
|
81
|
+
prompt: agent_data.prompt,
|
|
82
|
+
description: agent_data.description,
|
|
83
|
+
permission: {
|
|
84
|
+
bash: 'ask',
|
|
85
|
+
edit: 'allow',
|
|
86
|
+
webfetch: 'ask',
|
|
87
|
+
},
|
|
88
|
+
tools: {
|
|
89
|
+
[`${svelte_mcp_name}_*`]: true,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
156
92
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
93
|
+
// Get per-agent config from svelte.json (if any)
|
|
94
|
+
const agent_config = mcp_config.subagent?.agents?.[agent_name];
|
|
95
|
+
|
|
96
|
+
// Configure agent from svelte.json only
|
|
97
|
+
// Priority: svelte.json agent config > defaults
|
|
98
|
+
input.agent[agent_name] = {
|
|
99
|
+
...default_config,
|
|
100
|
+
...(agent_config?.model !== undefined && {
|
|
101
|
+
model: agent_config.model,
|
|
102
|
+
}),
|
|
103
|
+
...(agent_config?.temperature !== undefined && {
|
|
104
|
+
temperature: agent_config.temperature,
|
|
105
|
+
}),
|
|
106
|
+
...(agent_config?.maxSteps !== undefined && {
|
|
107
|
+
maxSteps: agent_config.maxSteps,
|
|
108
|
+
}),
|
|
109
|
+
...(agent_config?.top_p !== undefined && {
|
|
110
|
+
top_p: agent_config.top_p,
|
|
111
|
+
}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
174
114
|
}
|
|
175
115
|
},
|
|
176
116
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/opencode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sveltejs/ai-tools#readme",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"index.ts",
|
|
12
12
|
"config.ts",
|
|
13
|
+
"agents.ts",
|
|
13
14
|
"instructions",
|
|
14
15
|
"skills"
|
|
15
16
|
],
|