mirror of
https://github.com/sveltejs/ai-tools.git
synced 2026-07-04 11:42:22 +08:00
Compare commits
7 Commits
@sveltejs/
...
feat/error
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79e8436c6b | ||
|
|
c87ca0c8e8 | ||
|
|
46d8f6cce8 | ||
|
|
8dc63dca08 | ||
|
|
19fedcd35f | ||
|
|
b4eb5cc960 | ||
|
|
6676fd8116 |
5
.changeset/rich-wolves-double.md
Normal file
5
.changeset/rich-wolves-double.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@sveltejs/mcp': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: display similar result & error at the end
|
||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
name: Release
|
name: Release
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
outputs:
|
outputs:
|
||||||
published: ${{ steps.changesets.outputs.published }}
|
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# pseudo-matrix for convenience, NEVER use more than a single combination
|
# pseudo-matrix for convenience, NEVER use more than a single combination
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
|
|
||||||
publish-mcp:
|
publish-mcp:
|
||||||
needs: release
|
needs: release
|
||||||
if: needs.release.outputs.published == 'true'
|
if: contains(needs.release.outputs.publishedPackages, '"@sveltejs/mcp"')
|
||||||
uses: ./.github/workflows/publish-mcp.yml
|
uses: ./.github/workflows/publish-mcp.yml
|
||||||
secrets:
|
secrets:
|
||||||
MCP_KEY: ${{ secrets.MCP_KEY }}
|
MCP_KEY: ${{ secrets.MCP_KEY }}
|
||||||
|
|||||||
@@ -33,10 +33,13 @@ The default configuration for the Svelte OpenCode plugin looks like this...
|
|||||||
},
|
},
|
||||||
"skills": {
|
"skills": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
"instructions": {
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
...but if you prefer, you can enable only the subagent, only the MCP, only the skills, or configure the kind of MCP server you want to use (`local` or `remote`).
|
...but if you prefer, you can enable only the subagent, only the MCP, only the skills, or configure the kind of MCP server you want to use (`local` or `remote`).
|
||||||
|
|
||||||
You can place this file in `~/.config/opencode/svelte.json` or, if you have an `OPENCODE_CONFIG_DIR` environment variable specified, at `$OPENCODE_CONFIG_DIR/svelte.json`.
|
You can place this file in `./.opencode/svelte.json` (in your project), in `~/.config/opencode/svelte.json` or, if you have an `OPENCODE_CONFIG_DIR` environment variable specified, at `$OPENCODE_CONFIG_DIR/svelte.json`.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## `svelte-code-writer`
|
## `svelte-code-writer`
|
||||||
|
|
||||||
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.
|
CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating, editing or analyzing 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.
|
||||||
|
|
||||||
<a href="https://github.com/sveltejs/mcp/releases?q=svelte-code-writer" target="_blank" rel="noopener noreferrer">Open Releases page</a>
|
<a href="https://github.com/sveltejs/mcp/releases?q=svelte-code-writer" target="_blank" rel="noopener noreferrer">Open Releases page</a>
|
||||||
|
|
||||||
|
|||||||
@@ -91,16 +91,56 @@ export async function get_documentation_handler({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const has_any_success = results.some((result) => result.success);
|
const successes = results.filter((r) => r.success);
|
||||||
let final_text = results.map((r) => r.content).join('\n\n---\n\n');
|
const failed_sections = sections.filter(
|
||||||
|
(s) =>
|
||||||
|
!available_sections.some(
|
||||||
|
(a) => a.title.toLowerCase() === s.toLowerCase() || a.slug === s || a.url === s,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if (!has_any_success) {
|
if (successes.length > 0 && failed_sections.length === 0) {
|
||||||
const formatted_sections = await format_sections_list();
|
return successes.map((r) => r.content).join('\n\n---\n\n');
|
||||||
|
|
||||||
final_text += `\n\n---\n\n${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return final_text;
|
const parts: string[] = [];
|
||||||
|
|
||||||
|
if (successes.length > 0) {
|
||||||
|
parts.push(successes.map((r) => r.content).join('\n\n---\n\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const fuzzy_results = failed_sections.map((requested) => {
|
||||||
|
const lower = requested.toLowerCase();
|
||||||
|
const matches = available_sections.filter(
|
||||||
|
(a) =>
|
||||||
|
a.title.toLowerCase().includes(lower) ||
|
||||||
|
a.slug.includes(lower) ||
|
||||||
|
lower.includes(a.slug.split('/').pop() ?? '') ||
|
||||||
|
a.use_cases.toLowerCase().includes(lower),
|
||||||
|
);
|
||||||
|
return { requested, matches };
|
||||||
|
});
|
||||||
|
|
||||||
|
const has_fuzzy = fuzzy_results.some((r) => r.matches.length > 0);
|
||||||
|
|
||||||
|
// Full list only when no successes and no fuzzy matches
|
||||||
|
if (successes.length === 0 && !has_fuzzy) {
|
||||||
|
const formatted_sections = await format_sections_list();
|
||||||
|
parts.push(`${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similar results then errors
|
||||||
|
for (const { requested, matches } of fuzzy_results) {
|
||||||
|
if (matches.length > 0) {
|
||||||
|
const match_list = matches.map((m) => `- title: ${m.title}, section: ${m.slug}`).join('\n');
|
||||||
|
parts.push(
|
||||||
|
`${matches.length} similar result${matches.length > 1 ? 's' : ''} for "${requested}":\n${match_list}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parts.push(`Section not found: "${requested}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts.join('\n\n---\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_documentation(server: SvelteMcp) {
|
export function get_documentation(server: SvelteMcp) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: svelte-code-writer
|
name: svelte-code-writer
|
||||||
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.
|
description: CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating, editing or analyzing 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.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Svelte 5 Code Writer
|
# Svelte 5 Code Writer
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: svelte-code-writer
|
name: svelte-code-writer
|
||||||
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.
|
description: CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating, editing or analyzing 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.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Svelte 5 Code Writer
|
# Svelte 5 Code Writer
|
||||||
|
|||||||
Reference in New Issue
Block a user