Compare commits

..

100 Commits

Author SHA1 Message Date
Stanislav Khromov
62c5865ae9 Delete verify-distilled.test.ts 2025-10-14 21:25:10 +02:00
Stanislav Khromov
6b63f1565c format JSON files afte running scripts 2025-10-14 21:21:33 +02:00
Stanislav Khromov
4ba6ab893c format 2025-10-14 21:13:03 +02:00
Stanislav Khromov
931d959e2a update docs 2025-10-14 21:10:55 +02:00
Stanislav Khromov
d690939222 fix linting 2025-10-14 21:05:55 +02:00
Stanislav Khromov
8b80666572 Update .prettierignore 2025-10-14 21:05:27 +02:00
Stanislav Khromov
dc0e8428e5 format 2025-10-14 21:03:13 +02:00
Stanislav Khromov
e1e8476771 Update export-summaries.ts 2025-10-14 21:02:19 +02:00
Stanislav Khromov
a91c80e44b wip 2025-10-14 20:54:21 +02:00
Stanislav Khromov
6f7b24c584 generate markdown summaries 2025-10-14 20:39:55 +02:00
Stanislav Khromov
b5ea3c10db wip 2025-10-14 20:37:32 +02:00
Stanislav Khromov
504413c951 Update package.json 2025-10-14 20:36:56 +02:00
Stanislav Khromov
48230e8c47 clean up 2025-10-14 20:36:47 +02:00
Stanislav Khromov
e72a3d2c4a wip 2025-10-14 20:34:48 +02:00
Stanislav Khromov
ea4ae25035 Merge branch 'main' into improve-use-cases-and-summaries 2025-10-14 20:25:52 +02:00
Stanislav Khromov
b55db13ac9 Update show-verification-errors.ts 2025-10-13 01:23:21 +02:00
Stanislav Khromov
3e8ad5c47d wip 2025-10-13 01:20:33 +02:00
Stanislav Khromov
78be819cbe Delete generate-summaries.test.ts 2025-10-13 01:19:33 +02:00
Stanislav Khromov
0e7d5c3724 Revert "Update get-documentation.ts"
This reverts commit ca578583f2.
2025-10-13 01:09:35 +02:00
Stanislav Khromov
ca578583f2 Update get-documentation.ts 2025-10-13 01:03:04 +02:00
Stanislav Khromov
9208570fe2 Update utils.ts 2025-10-13 00:56:00 +02:00
Stanislav Khromov
28aee8eea6 Update CLAUDE.md 2025-10-13 00:53:51 +02:00
Stanislav Khromov
c05346626c wip 2025-10-13 00:46:14 +02:00
Stanislav Khromov
add959fd02 Update hooks.server.ts 2025-10-13 00:42:31 +02:00
Stanislav Khromov
cdb2a3eea8 wip 2025-10-13 00:36:13 +02:00
Stanislav Khromov
a4bbdf92e1 format 2025-10-13 00:34:57 +02:00
Stanislav Khromov
d5570e23d1 Update distilled.json 2025-10-13 00:34:18 +02:00
Stanislav Khromov
f81c7a2dd5 Update distilled.json 2025-10-13 00:26:21 +02:00
Stanislav Khromov
b11cbbccb5 Update package.json 2025-10-13 00:19:30 +02:00
Stanislav Khromov
b17f1e75ce wip 2025-10-13 00:15:31 +02:00
Stanislav Khromov
19a6c90ebb Update distilled-verification.json 2025-10-13 00:03:38 +02:00
Stanislav Khromov
af573abb82 Update verify-distilled.ts 2025-10-12 23:57:04 +02:00
Stanislav Khromov
f27a7778c7 wip 2025-10-12 23:49:16 +02:00
Stanislav Khromov
ff64389c68 Update prompts.ts 2025-10-12 23:35:32 +02:00
Stanislav Khromov
ea0624cf41 Update generate-summaries.ts 2025-10-12 23:34:02 +02:00
Stanislav Khromov
4079808b03 Add sorting controls to compare sections sidebar 2025-10-12 23:30:18 +02:00
Stanislav Khromov
43af0ac413 Move commander dependency to devDependencies 2025-10-12 23:13:31 +02:00
Stanislav Khromov
94d56fcaf5 Update +page.server.ts 2025-10-12 23:11:28 +02:00
Stanislav Khromov
4d0c1fdf3d Replace vite-node with node-resolve-ts in scripts 2025-10-12 23:08:55 +02:00
Stanislav Khromov
5ddd4c11a9 Update anthropic.ts 2025-10-12 00:08:32 +02:00
Stanislav Khromov
31cc38e1c1 fix vite-node import 2025-10-12 00:05:36 +02:00
Stanislav Khromov
1fe5383582 Update +page.server.ts 2025-10-12 00:03:53 +02:00
Stanislav Khromov
a22bd3df84 Update get-documentation.ts 2025-10-12 00:01:56 +02:00
Stanislav Khromov
0b846a8ae5 Update +page.svelte 2025-10-11 23:59:49 +02:00
Stanislav Khromov
cac9adf8cb Update +page.server.ts 2025-10-11 23:59:45 +02:00
Stanislav Khromov
9045e618c2 Update distilled.json 2025-10-11 23:40:49 +02:00
Stanislav Khromov
42b2a44b4b Update distilled.json 2025-10-11 23:38:42 +02:00
Stanislav Khromov
71eb1f770f don't restrict max_tokens 2025-10-11 23:31:49 +02:00
Stanislav Khromov
0482033c84 lint 2025-10-11 23:23:23 +02:00
Stanislav Khromov
8d5382d50d wip 2025-10-11 23:22:33 +02:00
Stanislav Khromov
ed1b018260 Update +page.svelte 2025-10-11 23:16:11 +02:00
Stanislav Khromov
9289421cd7 Update eslint.config.js 2025-10-11 23:14:42 +02:00
Stanislav Khromov
60610c6ebf format 2025-10-11 23:08:19 +02:00
Stanislav Khromov
1672ef7f94 Update .cocominify 2025-10-11 23:02:58 +02:00
Stanislav Khromov
34ae757b74 use vite-node for the scripts 2025-10-11 23:02:44 +02:00
Stanislav Khromov
ea9e3f425a Update utils.ts 2025-10-11 22:58:15 +02:00
Stanislav Khromov
3e991787f8 calc space savings 2025-10-11 22:57:56 +02:00
Stanislav Khromov
253f545c4d Update +page.svelte 2025-10-11 22:52:06 +02:00
Stanislav Khromov
d9a45a38b8 Update +page.svelte 2025-10-11 22:48:32 +02:00
Stanislav Khromov
b0d387ff36 wip 2025-10-11 22:48:09 +02:00
Stanislav Khromov
daec272ff8 wip 2025-10-11 22:46:06 +02:00
Stanislav Khromov
f2bda80b06 create visualization 2025-10-11 22:41:37 +02:00
Stanislav Khromov
1c9fc91c21 wip 2025-10-11 22:23:44 +02:00
Stanislav Khromov
24b9351a92 Update use_cases.json 2025-10-11 22:19:33 +02:00
Stanislav Khromov
e70db40d3c remove content hashes and use original content instead 2025-10-11 21:49:38 +02:00
Stanislav Khromov
7053cfcc2d write original content 2025-10-11 21:47:23 +02:00
Stanislav Khromov
2a640ba716 Update generate-summaries.ts 2025-10-11 21:41:02 +02:00
Stanislav Khromov
8273c6cba7 Update prompts.ts 2025-10-11 03:12:13 +02:00
Stanislav Khromov
dc039665d8 Update get-documentation.ts 2025-10-11 03:11:47 +02:00
Stanislav Khromov
9d4bf59b0c Update utils.ts 2025-10-11 03:10:42 +02:00
Stanislav Khromov
e528324785 wip 2025-10-11 03:07:02 +02:00
Stanislav Khromov
bb41d4a4cc Create distilled.json 2025-10-11 02:58:44 +02:00
Stanislav Khromov
24d22979ce Update package.json 2025-10-11 02:56:36 +02:00
Stanislav Khromov
d4fe086517 move prompts 2025-10-11 02:56:12 +02:00
Stanislav Khromov
30dc2eba84 Update generate-summaries.ts 2025-10-11 02:53:09 +02:00
Stanislav Khromov
ae92b84ffa Update generate-summaries.ts 2025-10-11 02:52:27 +02:00
Stanislav Khromov
eecaf8cd5a add distilled support 2025-10-11 02:51:12 +02:00
Stanislav Khromov
f1c72ae73c Update use_cases.json 2025-10-11 02:45:02 +02:00
Stanislav Khromov
02172d68cf remove unnecessary error checking 2025-10-11 02:39:19 +02:00
Stanislav Khromov
efd1d94c01 Update generate-summaries.test.ts 2025-10-11 02:31:53 +02:00
Stanislav Khromov
e347cc8caa Update generate-summaries.ts 2025-10-11 02:25:38 +02:00
Stanislav Khromov
15677b8ca4 wip 2025-10-11 02:22:54 +02:00
Stanislav Khromov
3a8e488a73 wip 2025-10-11 02:18:16 +02:00
Stanislav Khromov
1555c67a0f Update use_cases.json 2025-10-11 02:15:44 +02:00
Stanislav Khromov
4cbe859322 wip 2025-10-11 02:12:36 +02:00
Stanislav Khromov
a100bbb9be Update generate-summaries.ts 2025-10-11 02:08:19 +02:00
Stanislav Khromov
4344e09ce3 remove --sections 2025-10-11 01:53:47 +02:00
Stanislav Khromov
5fc108cf76 wip 2025-10-11 01:48:38 +02:00
Stanislav Khromov
740a08eb35 Update generate-summaries.ts 2025-10-11 01:43:32 +02:00
Stanislav Khromov
d054d48d6b Update generate-summaries.ts 2025-10-11 01:43:03 +02:00
Stanislav Khromov
4cdd419cd9 Create thirty-fans-stay.md 2025-10-11 01:42:02 +02:00
Stanislav Khromov
f1ff4d5862 Update generate-summaries.ts 2025-10-11 01:31:57 +02:00
Stanislav Khromov
6cbc72247e wip 2025-10-11 01:30:29 +02:00
Stanislav Khromov
98be540b18 Update generate-summaries.test.ts 2025-10-11 01:26:43 +02:00
Stanislav Khromov
2082ce91bc wip 2025-10-11 01:24:08 +02:00
Stanislav Khromov
9e2db4a7fa Update generate-summaries.ts 2025-10-11 01:19:35 +02:00
Stanislav Khromov
fe869d7a2c Update generate-summaries.ts 2025-10-11 01:19:10 +02:00
Stanislav Khromov
31ce09551c Update generate-summaries.ts 2025-10-11 01:18:19 +02:00
Stanislav Khromov
20bfbe09e3 wip 2025-10-11 01:18:08 +02:00
Stanislav Khromov
e3794491a4 Update .cocoignore 2025-10-11 01:08:58 +02:00
449 changed files with 22439 additions and 5520 deletions

View File

@@ -0,0 +1,5 @@
---
'@sveltejs/mcp': patch
---
fix: prevent `imported_runes` suggestion from being added for libs that are not svelte

View File

@@ -7,5 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["!@sveltejs/mcp", "!@sveltejs/opencode"]
"ignore": ["!@sveltejs/mcp"]
}

View File

@@ -0,0 +1,5 @@
---
'@sveltejs/mcp': minor
---
Adds LLM-condensed documentation for smaller context usage

View File

@@ -1,22 +0,0 @@
{
"name": "svelte",
"owner": {
"name": "Svelte"
},
"plugins": [
{
"name": "svelte",
"source": "./plugins/svelte",
"description": "A plugin for all things Svelte development, MCP, skills, and more.",
"lspServers": {
"svelte": {
"command": "svelteserver",
"args": ["--stdio"],
"extensionToLanguage": {
".svelte": "svelte"
}
}
}
}
]
}

View File

@@ -1,3 +1,4 @@
.claude
.github
.vscode
.vscode
documentation/

View File

@@ -1 +1,4 @@
packages/mcp-server/src/use_cases.json
packages/mcp-server/src/use_cases.json
packages/mcp-server/src/mcp/autofixers
packages/mcp-server/src/distilled.json
packages/mcp-server/src/distilled-verification.json

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
open_collective: svelte

View File

@@ -13,17 +13,17 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v6
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2
version: 10.18.2
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
uses: actions/setup-node@v6
with:
node-version: '24'
node-version: '22'
cache: 'pnpm'
- name: Install dependencies

View File

@@ -13,17 +13,17 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v6
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2
version: 10.18.2
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
uses: actions/setup-node@v6
with:
node-version: '24'
node-version: '22'
cache: 'pnpm'
- name: Install dependencies

View File

@@ -1,23 +0,0 @@
name: Publish Any Commit
on: [push, pull_request]
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- run: corepack enable
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- run: pnpm dlx pkg-pr-new publish --compact './packages/mcp-stdio' './packages/opencode' --pnpm

View File

@@ -5,7 +5,6 @@ on:
secrets:
MCP_KEY:
required: true
workflow_dispatch:
jobs:
publish-mcp:
@@ -13,19 +12,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v6
uses: actions/checkout@v5
- name: Publish to MCP Registry
working-directory: packages/mcp-stdio
env:
MCP_KEY: ${{ secrets.MCP_KEY }}
run: |
NAME=mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
# Download MCP Publisher pinned to v1.4.0 using latest https for security and save it to a file named mcp-publisher.tar.gz
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL "https://github.com/modelcontextprotocol/registry/releases/download/v1.4.0/$NAME" -O
NAME=mcp-publisher_1.2.3_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
# Download MCP Publisher pinned to v1.2.3 using latest https for security and save it to a file named mcp-publisher.tar.gz
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL "https://github.com/modelcontextprotocol/registry/releases/download/v1.2.3/$NAME" -O
# Verify the SHA256 checksum of the downloaded file
sha256sum --ignore-missing -c ./checksums/registry_1.4.0_checksums.txt
sha256sum --ignore-missing -c ./checksums/registry_1.2.3_checksums.txt
# Extract the tarball
mkdir tmp

View File

@@ -1,45 +0,0 @@
name: Release Svelte Code Writer Skill
on:
push:
branches:
- main
paths:
- 'plugins/svelte/skills/svelte-code-writer/**'
workflow_dispatch:
permissions: {}
jobs:
release:
permissions:
contents: write
# prevents this action from running on forks
if: github.repository == 'sveltejs/mcp'
name: Release Svelte Code Writer Skill
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v6
- name: Get version from date
id: version
run: echo "version=$(date +'%Y.%m.%d-%H%M%S')" >> $GITHUB_OUTPUT
- name: Create zip
run: |
cd plugins/svelte/skills
zip -r svelte-code-writer.zip svelte-code-writer/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: svelte-code-writer-v${{ steps.version.outputs.version }}
name: Svelte Code Writer Skill v${{ steps.version.outputs.version }}
body: |
Automated release of the Svelte Code Writer skill.
This release was triggered by changes to the `plugins/svelte/skills/svelte-code-writer/` directory.
files: plugins/svelte/skills/svelte-code-writer.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -25,11 +25,11 @@ jobs:
os: [ubuntu-latest]
steps:
- name: checkout
uses: actions/checkout@v6
uses: actions/checkout@v5
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
package-manager-cache: false # pnpm is not installed yet
@@ -39,11 +39,10 @@ jobs:
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
package-manager-cache: true # caches pnpm via packageManager field in package.json
cache: 'pnpm'
- name: install
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: build
@@ -52,7 +51,7 @@ jobs:
- name: Create Release Pull Request or Publish to npm
id: changesets
# pinned for security, always review third party action code before updating
uses: changesets/action@c48e67d110a68bc90ccf1098e9646092baacaa87 # v1.6.0
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
with:
# This expects you to have a script called changeset:version version that calls changeset version and updated what it needs to be updated
version: pnpm changeset:version

View File

@@ -1,71 +0,0 @@
name: Sync Agents Documentation
on:
push:
branches:
- main
paths:
- 'instructions/AGENTS.md'
permissions:
contents: write
pull-requests: write
jobs:
sync-agents:
# prevents this action from running on forks
if: github.repository == 'sveltejs/mcp'
name: Sync AGENTS.md to OpenCode Package and Docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
package-manager-cache: false # pnpm is not installed yet
- name: Install pnpm
shell: bash
run: |
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- name: Sync AGENTS.md
run: pnpm sync-agents-md
- name: Check for changes
id: git-check
run: |
git diff --exit-code packages/opencode/instructions/opencode-agents.md documentation/docs/10-introduction/.generated/agents.md || echo "changed=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: sync AGENTS.md to opencode package and documentation'
branch: chore/sync-agents-md
delete-branch: true
title: 'chore: sync AGENTS.md to opencode package and documentation'
body: |
## Summary
Automatically synced AGENTS.md to the opencode package and documentation.
This PR was triggered by changes to `instructions/AGENTS.md`.
## Changes
- Synced `packages/opencode/instructions/opencode-agents.md` with latest AGENTS.md
- Updated `documentation/docs/10-introduction/.generated/agents.md` with latest content
## Generated by
GitHub Action: Sync Agents Documentation
labels: |
chore
documentation
automated

View File

@@ -1,84 +0,0 @@
name: Sync OpenCode Skills
on:
push:
branches:
- main
paths:
- 'plugins/svelte/skills/**'
permissions:
contents: write
pull-requests: write
jobs:
sync-skills:
# prevents this action from running on forks
if: github.repository == 'sveltejs/mcp'
name: Sync Skills to OpenCode Package and Update Docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
package-manager-cache: false # pnpm is not installed yet
- name: Install pnpm
shell: bash
run: |
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- name: Setup Node.js with pnpm cache
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
package-manager-cache: true # caches pnpm via packageManager field in package.json
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: Sync skills folder
run: pnpm sync-opencode-skills
- name: Generate skills documentation
run: pnpm generate-skill-docs
- name: Check for changes
id: git-check
run: |
git diff --exit-code packages/opencode/skills documentation/docs/60-skills/10-skills.md || echo "changed=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: sync skills and update documentation'
branch: chore/sync-opencode-skills
delete-branch: true
title: 'chore: sync skills and update documentation'
body: |
## Summary
Automatically synced skills and updated documentation.
This PR was triggered by changes to the skills folder in `plugins/svelte/skills/`.
## Changes
- Synced `packages/opencode/skills/` with latest skill definitions
- Updated `documentation/docs/60-skills/10-skills.md` with latest skill documentation
## Generated by
GitHub Action: Sync OpenCode Skills
labels: |
chore
documentation
automated

View File

@@ -13,17 +13,17 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v6
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2
version: 10.18.2
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
uses: actions/setup-node@v6
with:
node-version: '24'
node-version: '22'
cache: 'pnpm'
- name: Install dependencies

View File

@@ -1,78 +0,0 @@
name: Update OpenCode JSON Schema
on:
push:
branches:
- main
paths:
- 'packages/opencode/config.ts'
permissions:
contents: write
pull-requests: write
jobs:
update-docs:
# prevents this action from running on forks
if: github.repository == 'sveltejs/mcp'
name: Update OpenCode JSON Schema
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
package-manager-cache: false # pnpm is not installed yet
- name: Install pnpm
shell: bash
run: |
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- name: Setup Node.js with pnpm cache
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
package-manager-cache: true # caches pnpm via packageManager field in package.json
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: Generate opencode JSON schema
run: pnpm generate-opencode-jsonschema
- name: Check for changes
id: git-check
run: |
git diff --exit-code packages/opencode/schema.json || echo "changed=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'docs: update opencode JSON schema'
branch: docs/update-opencode-jsonschema
delete-branch: true
title: 'docs: update opencode JSON schema'
body: |
## Summary
Automatically generated update for OpenCode JSON schema.
This PR was triggered by changes to the OpenCode configuration file `packages/opencode/config.ts`.
## Changes
- Updated `packages/opencode/schema.json` with latest JSON schema
## Generated by
GitHub Action: Update OpenCode JSON Schema
labels: |
automated

View File

@@ -19,12 +19,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false # pnpm is not installed yet
@@ -37,11 +37,10 @@ jobs:
npm i -g pnpm@$PNPM_VER
- name: Setup Node.js with pnpm cache
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: true # caches pnpm via packageManager field in package.json
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
@@ -56,7 +55,7 @@ jobs:
- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'docs: update prompts documentation'

View File

@@ -12,6 +12,6 @@ bun.lockb
# Claude Code
.claude/
.changeset/
/packages/opencode/schema.json
# MCP Server Markdown Files
packages/mcp-server/**/*.md

View File

@@ -12,7 +12,6 @@
"body": [
"import type { SvelteMcp } from '../../index.js';",
"import * as v from 'valibot';",
"import { icons } from '../../icons/index.js';",
"",
"export function ${1:function_name}(server: SvelteMcp) {",
"\t$0",
@@ -36,7 +35,6 @@
"prefix": "!prompt",
"body": [
"import type { SvelteMcp } from '../../index.js';",
"import { icons } from '../../icons/index.js';",
"",
"/**",
" * Function that actually generates the prompt string. You can use this in the MCP server handler to generate the prompt, it can accept arguments",
@@ -71,7 +69,6 @@
"\t\t\ttitle: '${2:title}',",
"\t\t\tdescription:",
"\t\t\t\t'${3:llm_description}',",
"\t\t\ticons,",
"\t\t},",
"\t\tasync () => {",
"\t\t\treturn {",

302
CLAUDE.md
View File

@@ -2,72 +2,234 @@
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Development Commands
## Project Structure
This is a Svelte MCP (Model Context Protocol) server implementation that includes both SvelteKit web interface and MCP server functionality.
This is a monorepo containing the official Svelte MCP (Model Context Protocol) server implementation with multiple packages:
- **`packages/mcp-server/`** - Core MCP server logic with tools, prompts, and autofixers
- **`packages/mcp-stdio/`** - CLI wrapper for running MCP server via stdio transport (`@sveltejs/mcp` on npm)
- **`packages/mcp-schema/`** - Shared database schema definitions using Drizzle ORM
- **`apps/mcp-remote/`** - SvelteKit web application for remote HTTP MCP access and documentation comparison
## Development Commands
### Setup
```bash
pnpm i
cp .env.example .env
# Set the VOYAGE_API_KEY for embeddings support in .env
cp apps/mcp-remote/.env.example apps/mcp-remote/.env
# Set DATABASE_URL, DATABASE_TOKEN, and VOYAGE_API_KEY (optional) in apps/mcp-remote/.env
pnpm dev
```
### Common Commands
- `pnpm dev` - Start SvelteKit development server
- `pnpm build` - Build the application for production
- `pnpm start` - Run the MCP server (Node.js entry point)
- `pnpm check` - Run Svelte type checking
- `pnpm check:watch` - Run type checking in watch mode
- `pnpm dev` - Start SvelteKit development server (apps/mcp-remote)
- `pnpm build` - Build all packages
- `pnpm check` - Run type checking across all packages
- `pnpm lint` - Run prettier check and eslint
- `pnpm lint:fix` - Auto-fix linting issues
- `pnpm format` - Format code with prettier
- `pnpm test` - Run unit tests with vitest
- `pnpm test:watch` - Run tests in watch mode
### Database Commands (Drizzle ORM)
### Database Commands (apps/mcp-remote)
- `pnpm db:push` - Push schema changes to database
- `pnpm db:push` - Push schema changes to Turso database
- `pnpm db:generate` - Generate migration files
- `pnpm db:migrate` - Run migrations
- `pnpm db:studio` - Open Drizzle Studio
### Documentation Generation Commands (packages/mcp-server)
#### Generate Use Case Summaries
Generate short descriptions of when each documentation section would be useful:
- `pnpm generate-summaries` - Generate use case summaries for all sections
- `pnpm generate-summaries:dry-run` - Preview what would be generated without making API calls
- `pnpm generate-summaries:debug` - Process only 2 sections for debugging
#### Generate Distilled Documentation
Generate condensed versions of the documentation to reduce context size:
- `pnpm generate-distilled` - Generate distilled versions for all sections
- `pnpm generate-distilled:dry-run` - Preview what would be generated without making API calls
- `pnpm generate-distilled:debug` - Process only 2 sections for debugging
#### Verify Distilled Documentation
Verify the accuracy of distilled summaries against original documentation:
- `pnpm verify-distilled` - Verify all distilled summaries for accuracy
- `pnpm show-verification-errors` - Display all sections that failed verification
The verification workflow:
1. Run `pnpm verify-distilled` to verify all distilled summaries
- Loads `distilled.json` containing summaries and original content
- Uses the Anthropic Batch API to send each summary and original content to Claude
- Claude evaluates whether the summary is accurate or contains errors/omissions
- Generates `distilled-verification.json` with results (ACCURATE/NOT_ACCURATE) and reasoning
- Outputs statistics about accuracy rates
2. Run `pnpm show-verification-errors` to see detailed list of all sections that are NOT_ACCURATE
- Displays each problematic section with its reasoning
- Shows summary statistics
**Note:** All documentation generation and verification commands require `ANTHROPIC_API_KEY` to be set in `packages/mcp-server/.env`
### Documentation Updates
- `pnpm generate-prompt-docs` - Update documentation/docs/30-capabilities/30-prompts.md based on prompt handlers
### Publishing Commands
- `pnpm release` - Build and publish to npm using changesets
- `pnpm changeset:version` - Update versions and sync package.json with server.json
### Development Tools
- `pnpm inspect` - Launch MCP inspector at http://localhost:6274/ for testing tools and prompts
## Architecture
### MCP Server Implementation
### MCP Server Implementation (`packages/mcp-server/src/mcp/`)
The core MCP server is implemented in `src/lib/mcp/index.ts` using the `tmcp` library with:
The core MCP server is implemented using the `tmcp` library with:
- **Transport Layers**: Both HTTP (`HttpTransport`) and STDIO (`StdioTransport`) support
- **Transport Layers**: Both HTTP (`@tmcp/transport-http`) and STDIO (`@tmcp/transport-stdio`) support
- **Schema Validation**: Uses Valibot with `ValibotJsonSchemaAdapter`
- **Main Tool**: `svelte-autofixer` - analyzes Svelte code and provides suggestions/fixes
- **Server Definition**: `packages/mcp-server/src/mcp/index.ts` exports the configured server instance
### Code Analysis Engine
### MCP Tools (`packages/mcp-server/src/mcp/handlers/tools/`)
Located in `src/lib/server/analyze/`:
#### get-documentation
- **Parser** (`parse.ts`): Uses `svelte-eslint-parser` and TypeScript parser to analyze Svelte components
Retrieves documentation content for Svelte 5 or SvelteKit sections. Supports:
- Single or multiple section names
- Search by title (e.g., "$state") or file path (e.g., "cli/overview")
- Optional distilled versions to optimize context size (default: true)
- Automatically loads distilled content from `distilled.json` when available
#### list-sections
Lists all available Svelte 5 and SvelteKit documentation sections with:
- Section titles and file paths
- "use_cases" metadata describing when each section is useful
- Helps LLMs determine which documentation to fetch
#### svelte-autofixer
Analyzes Svelte component or module code and returns suggestions/fixes:
- Runs compilation checks
- Runs ESLint checks
- Runs custom autofixer visitors
- Requires `code`, `desired_svelte_version` (4 or 5), and optional `filename`
- Returns issues, suggestions, and whether another tool call is needed
#### playground-link
Generates a Svelte Playground link from code snippets:
- Accepts multiple files (must include `App.svelte` as entry point)
- Optional Tailwind CSS support
- Compresses and encodes files into URL hash
### MCP Prompts (`packages/mcp-server/src/mcp/handlers/prompts/`)
#### svelte-task
A prompt template that instructs LLMs on how to:
- Query available documentation sections
- Use the autofixer iteratively until no issues remain
- Generate playground links when appropriate
- Follows best practices for Svelte development
Prompts are defined with:
- `generate_for_docs()` - Function to generate prompt text for documentation
- `docs_description` - Human-readable description
- Prompt handler - Server registration logic with schema and completions
### MCP Resources (`packages/mcp-server/src/mcp/handlers/resources/`)
#### Svelte-Doc-Section
URI template: `svelte://{/slug*}.md`
Lists and fetches individual documentation sections:
- Lists all sections with metadata (title, use_cases, URI)
- Provides completions for slug parameter
- Fetches content from svelte.dev/docs/
### Code Analysis & Parsing (`packages/mcp-server/src/parse/`)
- **Parser** (`parse.ts`): Uses `svelte-eslint-parser` and TypeScript parser
- **Scope Analysis**: Tracks variables, references, and scopes across the AST
- **Rune Detection**: Identifies Svelte 5 runes (`$state`, `$effect`, `$derived`, etc.)
### Autofixer System
### Autofixer System (`packages/mcp-server/src/mcp/autofixers/`)
- **Autofixers** (`src/lib/mcp/autofixers.ts`): Visitor pattern implementations for code analysis
- **Walker Utility** (`src/lib/index.ts`): Enhanced AST walking with visitor mixing capabilities
- **Current Autofixer**: `assign_in_effect` - detects assignments to `$state` variables inside `$effect` blocks
The autofixer system uses a visitor pattern to analyze Svelte components:
### Database Layer
#### Core Autofixer Files
- **ORM**: Drizzle with SQLite backend
- **Schema** (`src/lib/server/db/schema.ts`): Vector table for embeddings support
- **Utils** (`src/lib/server/db/utils.ts`): Custom float32 array type for vectors
- **`add-compile-issues.ts`** - Runs Svelte compiler and adds compilation errors
- **`add-eslint-issues.ts`** - Runs ESLint with svelte-eslint-parser
- **`add-autofixers-issues.ts`** - Orchestrates all custom autofixer visitors
### SvelteKit Integration
#### AST Walking (`ast/`)
- **`walk.ts`** - Enhanced AST walking with visitor mixing capabilities using zimmerframe
- **`utils.ts`** - Utility functions for AST manipulation
#### Autofixer Visitors (`visitors/`)
Each visitor checks for specific issues:
- **`assign-in-effect.ts`** - Detects assignments to `$state` variables inside `$effect` blocks
- **`derived-with-function.ts`** - Suggests using `$derived.by()` when passing a function to `$derived()`
- **`imported-runes.ts`** - Detects attempts to import runes (they're globals)
- **`read-state-with-dollar.ts`** - Detects reading `$state` variables with `$` prefix in Svelte 5
- **`suggest-attachments.ts`** - Suggests attachments API for bind:this and actions
- **`use-runes-instead-of-store.ts`** - Suggests migrating from stores to runes in Svelte 5
- **`wrong-property-access-state.ts`** - Detects incorrect property access patterns on `$state` variables
### Database Layer (`packages/mcp-schema/`)
- **ORM**: Drizzle with LibSQL/Turso backend
- **Schema** (`src/schema.js`):
- `content` - Original documentation with embeddings
- `content_distilled` - Distilled/condensed documentation with embeddings
- `distillations` - Stored distilled documentation versions
- `distillation_jobs` - Batch processing job tracking
- **Utils** (`src/utils.js`): Custom `float_32_array` type for vector embeddings
### SvelteKit Web App (`apps/mcp-remote/`)
Remote HTTP MCP server with documentation comparison interface:
- **Hooks** (`src/hooks.server.ts`): Integrates MCP HTTP transport with SvelteKit requests
- **Routes**: Basic web interface for the MCP server
- **Routes**:
- `/` - Landing page
- `/compare/use_cases` - Compare use case summaries with original docs
- `/compare/distilled` - Compare distilled docs with original docs
- **MCP Setup** (`src/lib/mcp/index.ts`): HTTP transport configuration
### CLI Package (`packages/mcp-stdio/`)
Standalone npm package (`@sveltejs/mcp`) that:
- Runs the MCP server via stdio transport
- Built with tsdown for optimal bundling
- Externalizes `eslint` dependency (required at runtime)
- Published to npm registry and MCP registry
## Key Dependencies
@@ -75,27 +237,87 @@ Located in `src/lib/server/analyze/`:
- **@tmcp/transport-http** & **@tmcp/transport-stdio**: Transport layers
- **@tmcp/adapter-valibot**: Schema validation adapter
- **svelte-eslint-parser**: Svelte component parsing
- **typescript-eslint**: TypeScript AST parsing
- **zimmerframe**: AST walking utilities
- **drizzle-orm**: Database ORM with SQLite
- **drizzle-orm**: Database ORM with LibSQL
- **valibot**: Schema validation library
- **@anthropic-ai/sdk**: Anthropic Batch API for documentation processing
- **tsdown**: TypeScript bundler for CLI package
## Environment Configuration
Required environment variables:
### apps/mcp-remote/.env
- `DATABASE_URL`: SQLite database path (default: `file:test.db`)
- `VOYAGE_API_KEY`: API key for embeddings support (optional)
Required for the remote MCP server:
When connected to the svelte-llm MCP server, you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
- `DATABASE_URL`: LibSQL/Turso database URL (e.g., `libsql://db-name.turso.io`)
- `DATABASE_TOKEN`: Turso authentication token
- `VOYAGE_API_KEY`: API key for embeddings support (optional, for vector search features)
## Available MCP Tools:
### packages/mcp-server/.env
### 1. list-sections
Required for documentation generation scripts:
Use this FIRST to discover all available documentation sections. Returns a structured list with titles and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
- `ANTHROPIC_API_KEY`: API key for generating and verifying distilled documentation
### 2. get-documentation
## Using the MCP Server
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections and then use the get_documentation tool to fetch ALL documentation sections that are relevant for the users task.
### Available MCP Tools
1. **list-sections** - ALWAYS call this FIRST to discover available documentation
- Returns structured list with titles, paths, and use_cases metadata
- Use the use_cases field to determine relevant sections
2. **get-documentation** - Retrieves documentation content
- Accepts single section name or array of section names
- Searches by title or file path
- Optional `use_distilled` parameter (default: true) for condensed versions
- After calling list-sections, fetch ALL relevant sections at once
3. **svelte-autofixer** - Analyzes Svelte code
- MUST be used whenever writing Svelte code before returning to user
- Keep calling until no issues/suggestions remain
- Provides compilation errors, ESLint issues, and custom suggestions
4. **playground-link** - Generates Svelte Playground URLs
- Only use after code is finalized and user confirms
- Requires App.svelte as entry point
- Can include multiple files
### Available MCP Prompts
- **svelte-task** - Use for any Svelte-related task
- Instructs LLM on proper tool usage
- Enforces iterative autofixer workflow
- Guides documentation querying
## Constants & Configuration
### Svelte Runes (`packages/mcp-server/src/constants.ts`)
Base runes:
- `$state`, `$effect`, `$derived`, `$inspect`, `$props`, `$bindable`, `$host`
Nested runes:
- `$state.raw`, `$state.snapshot`, `$effect.pre`, `$effect.tracking`, `$effect.pending`, `$effect.root`, `$derived.by`, `$inspect.trace`, `$props.id`
## Code Style & Standards
- **Naming**: Use `snake_case` for variables and functions
- **Types**: Prefer TypeScript type imports with JSDoc where needed
- **Formatting**: Tabs for indentation, single quotes, trailing commas
- **File Extensions**: Include `.js` extension in imports even for TypeScript files
- **Linting**: Run `pnpm lint:fix` before committing
## Testing
- Unit tests use Vitest
- Test files use `.test.ts` or `.spec.ts` suffix
- Run `pnpm test` to execute all tests
- Run `pnpm test:watch` for watch mode
- Test coverage includes:
- Documentation generation and verification
- Autofixer visitors
- Parsing and AST analysis

View File

@@ -37,35 +37,34 @@
],
"private": true,
"devDependencies": {
"@eslint/compat": "catalog:lint",
"@eslint/js": "catalog:lint",
"@libsql/client": "catalog:orm",
"@modelcontextprotocol/inspector": "catalog:ai",
"@sveltejs/adapter-vercel": "catalog:svelte",
"@sveltejs/kit": "catalog:svelte",
"@sveltejs/vite-plugin-svelte": "catalog:svelte",
"@types/node": "catalog:tooling",
"@typescript-eslint/parser": "catalog:lint",
"drizzle-kit": "catalog:orm",
"drizzle-orm": "catalog:orm",
"eslint-config-prettier": "catalog:lint",
"eslint-plugin-svelte": "catalog:lint",
"globals": "catalog:lint",
"prettier": "catalog:lint",
"prettier-plugin-svelte": "catalog:lint",
"svelte": "catalog:svelte",
"svelte-check": "catalog:svelte",
"svelte-eslint-parser": "catalog:lint",
"typescript": "catalog:tooling",
"vite": "catalog:tooling",
"vite-plugin-devtools-json": "catalog:tooling",
"vitest": "catalog:tooling"
"@eslint/compat": "^1.3.2",
"@eslint/js": "^9.36.0",
"@libsql/client": "^0.15.0",
"@modelcontextprotocol/inspector": "^0.17.0",
"@sveltejs/adapter-vercel": "^5.6.3",
"@sveltejs/kit": "^2.22.0",
"@sveltejs/vite-plugin-svelte": "^6.0.0",
"@types/node": "^24.3.1",
"@typescript-eslint/parser": "^8.44.0",
"drizzle-kit": "^0.31.0",
"drizzle-orm": "^0.44.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^3.12.3",
"globals": "^16.0.0",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"svelte-eslint-parser": "^1.3.2",
"typescript": "^5.0.0",
"vite": "^7.0.4",
"vite-plugin-devtools-json": "^1.0.0",
"vitest": "^3.2.3"
},
"dependencies": {
"@sveltejs/mcp-schema": "workspace:^",
"@sveltejs/mcp-server": "workspace:^",
"@tmcp/transport-http": "catalog:tmcp",
"@vercel/analytics": "catalog:tooling",
"tmcp": "catalog:tmcp"
"@tmcp/transport-http": "^0.6.3",
"tmcp": "^1.14.0"
}
}

View File

@@ -1,15 +1,16 @@
import { dev } from '$app/environment';
import { http_transport } from '$lib/mcp/index.js';
import { db } from '$lib/server/db/index.js';
import { redirect } from '@sveltejs/kit';
import { track } from '@vercel/analytics/server';
export async function handle({ event, resolve }) {
if (event.request.method === 'GET') {
const accept = event.request.headers.get('accept');
if (accept) {
const accepts = accept.split(',');
if (!accepts.includes('text/event-stream')) {
if (
!accepts.includes('text/event-stream') &&
(event.url.pathname.startsWith('/mcp') || event.url.pathname === '/')
) {
// the request it's a browser request, not an MCP client request
// it means someone probably opened it from the docs...we should redirect to the docs
redirect(302, 'https://svelte.dev/docs/mcp/overview');
@@ -18,12 +19,20 @@ export async function handle({ event, resolve }) {
}
const mcp_response = await http_transport.respond(event.request, {
db,
// only add analytics in production
track: dev
? undefined
: async (session_id, event, extra) => {
await track(event, { session_id, ...(extra ? { extra } : {}) });
},
});
// we are deploying on vercel the SSE connection will timeout after 5 minutes...for
// the moment we are not sending back any notifications (logs, or list changed notifications)
// so it's a waste of resources to keep a connection open that will error
// after 5 minutes making the logs dirty. For this reason if we have a response from
// the MCP server and it's a GET request we just return an empty response (it has to be
// 200 or the MCP client will complain)
if (mcp_response && event.request.method === 'GET') {
try {
await mcp_response.body?.cancel();
} catch {
// ignore
}
return new Response('', { status: 200 });
}
return mcp_response ?? resolve(event);
}

View File

@@ -3,10 +3,4 @@ import { HttpTransport } from '@tmcp/transport-http';
export const http_transport = new HttpTransport(server, {
cors: true,
path: '/mcp',
// we are deploying on vercel the SSE connection will timeout after 5 minutes...for
// the moment we are not sending back any notifications (logs, or list changed notifications)
// so it's a waste of resources to keep a connection open that will error
// after 5 minutes making the logs dirty.
disableSse: true,
});

View File

@@ -1,6 +1,8 @@
import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql';
import * as schema from './schema.js';
// let's disable it for the moment...i can't figure out a way to make it wotk with eslint
// eslint-disable-next-line import/extensions
import { DATABASE_TOKEN, DATABASE_URL } from '$env/static/private';
if (!DATABASE_URL) throw new Error('DATABASE_URL is not set');
if (!DATABASE_TOKEN) throw new Error('DATABASE_TOKEN is not set');

View File

@@ -1 +0,0 @@
<h1>Official Svelte MCP</h1>

View File

@@ -0,0 +1,73 @@
import { error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import distilled_data from '@sveltejs/mcp-server/distilled.json';
import use_cases_data from '@sveltejs/mcp-server/use-cases.json';
interface SummaryData {
generated_at: string;
model: string;
total_sections: number;
successful_summaries: number;
summaries: Record<string, string>;
content: Record<string, string>;
}
const VALID_TYPES = ['use_cases', 'distilled'] as const;
type ValidType = (typeof VALID_TYPES)[number];
function is_valid_type(type: string): type is ValidType {
return VALID_TYPES.includes(type as ValidType);
}
export const load: PageServerLoad = async ({ params }) => {
const { type } = params;
if (!is_valid_type(type)) {
throw error(404, 'Comparison type not found');
}
const data = (type === 'use_cases' ? use_cases_data : distilled_data) as SummaryData;
const sections = Object.keys(data.summaries).map((slug) => {
const summary = data.summaries[slug] || '';
const content = data.content[slug] || '';
const original_length = content.length;
const distilled_length = summary.length;
const space_savings =
original_length > 0 ? ((original_length - distilled_length) / original_length) * 100 : 0;
return {
slug,
summary,
content,
original_length,
distilled_length,
space_savings,
};
});
const total_original_length = sections.reduce((sum, s) => sum + s.original_length, 0);
const total_distilled_length = sections.reduce((sum, s) => sum + s.distilled_length, 0);
const total_space_savings =
total_original_length > 0
? ((total_original_length - total_distilled_length) / total_original_length) * 100
: 0;
const title =
type === 'use_cases' ? 'Use Cases Comparison' : 'Distilled Documentation Comparison';
return {
type,
title,
metadata: {
generated_at: data.generated_at,
model: data.model,
total_sections: data.total_sections,
successful_summaries: data.successful_summaries,
total_original_length,
total_distilled_length,
total_space_savings,
},
sections,
};
};

View File

@@ -0,0 +1,427 @@
<script lang="ts">
import type { PageData } from './$types';
let { data }: { data: PageData } = $props();
let selected_slug = $state<string | null>(null);
let search_query = $state('');
let sort_order = $state<'default' | 'largest' | 'smallest'>('default');
let filtered_sections = $derived.by(() => {
// First, filter sections
const filtered = data.sections.filter(
(section) =>
section.slug.toLowerCase().includes(search_query.toLowerCase()) ||
section.summary.toLowerCase().includes(search_query.toLowerCase()),
);
// Then, sort based on selected sort order
if (sort_order === 'largest') {
return [...filtered].sort((a, b) => b.space_savings - a.space_savings);
} else if (sort_order === 'smallest') {
return [...filtered].sort((a, b) => a.space_savings - b.space_savings);
}
return filtered;
});
let selected_section = $derived(
selected_slug ? data.sections.find((s) => s.slug === selected_slug) : null,
);
let summary_title = $derived(
data.type === 'use_cases' ? 'Use Cases Summary' : 'Distilled Version',
);
let is_distilled = $derived(data.type === 'distilled');
function select_section(slug: string) {
selected_slug = selected_slug === slug ? null : slug;
}
</script>
<svelte:head>
<title>{data.title}</title>
</svelte:head>
<div class="container">
<header>
<h1>{data.title}</h1>
<div class="metadata">
<span>Generated: {new Date(data.metadata.generated_at).toLocaleString()}</span>
<span>Model: {data.metadata.model}</span>
<span>Sections: {data.metadata.successful_summaries}/{data.metadata.total_sections}</span>
<span
>Space Savings: {data.metadata.total_distilled_length.toLocaleString()}/{data.metadata.total_original_length.toLocaleString()}
chars ({data.metadata.total_space_savings.toFixed(1)}% reduction)</span
>
</div>
</header>
<div class="main-content">
<aside class="sidebar">
<div class="sort-controls">
<span class="sort-label">Sort by:</span>
<div class="sort-buttons">
<button
class="sort-button"
class:active={sort_order === 'default'}
onclick={() => (sort_order = 'default')}
>
Default
</button>
<button
class="sort-button"
class:active={sort_order === 'largest'}
onclick={() => (sort_order = 'largest')}
>
Largest Reduction
</button>
<button
class="sort-button"
class:active={sort_order === 'smallest'}
onclick={() => (sort_order = 'smallest')}
>
Smallest Reduction
</button>
</div>
</div>
<div class="search-box">
<input
type="search"
bind:value={search_query}
placeholder="Search sections..."
class="search-input"
/>
</div>
<ul class="section-list">
{#each filtered_sections as section (section.slug)}
<li>
<button
class="section-item"
class:active={selected_slug === section.slug}
onclick={() => select_section(section.slug)}
>
<div class="section-header">
<div class="section-title">{section.slug}</div>
<div class="section-savings" class:negative={section.space_savings < 0}>
{section.space_savings.toFixed(1)}%
</div>
</div>
<div class="section-preview">
{is_distilled
? section.summary.slice(0, 100) + (section.summary.length > 100 ? '...' : '')
: section.summary}
</div>
</button>
</li>
{/each}
</ul>
</aside>
<main class="comparison-view">
{#if selected_section}
<div class="comparison-grid">
<div class="comparison-column">
<h2>
Original Content
<span class="char-count"
>{selected_section.original_length.toLocaleString()} chars</span
>
</h2>
<div class="content-box">
<pre>{selected_section.content}</pre>
</div>
</div>
<div class="comparison-column">
<h2>
{summary_title}
<span class="char-count"
>{selected_section.distilled_length.toLocaleString()} chars ({selected_section.space_savings.toFixed(
1,
)}% savings)</span
>
</h2>
<div class="content-box">
<pre>{selected_section.summary}</pre>
</div>
</div>
</div>
{:else}
<div class="empty-state">
<p>Select a section from the list to view the comparison</p>
</div>
{/if}
</main>
</div>
</div>
<style>
.container {
max-width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
}
header {
background: white;
border-bottom: 1px solid #e0e0e0;
padding: 1.5rem 2rem;
}
h1 {
margin: 0 0 0.5rem 0;
font-size: 1.875rem;
font-weight: 600;
color: #1a1a1a;
}
.metadata {
display: flex;
gap: 1.5rem;
font-size: 0.9375rem;
color: #666;
flex-wrap: wrap;
}
.main-content {
display: flex;
flex: 1;
overflow: hidden;
}
.sidebar {
width: 350px;
background: white;
border-right: 1px solid #e0e0e0;
display: flex;
flex-direction: column;
}
.sort-controls {
padding: 1rem;
border-bottom: 1px solid #e0e0e0;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.sort-label {
font-size: 0.8125rem;
font-weight: 500;
color: #666;
}
.sort-buttons {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.sort-button {
padding: 0.375rem 0.75rem;
border: 1px solid #e0e0e0;
border-radius: 4px;
background: white;
font-size: 0.8125rem;
font-family: inherit;
cursor: pointer;
transition: all 0.15s;
color: #666;
}
.sort-button:hover {
background: #f9fafb;
border-color: #d0d0d0;
}
.sort-button.active {
background: #3b82f6;
border-color: #3b82f6;
color: white;
}
.search-box {
padding: 1rem;
border-bottom: 1px solid #e0e0e0;
}
.search-input {
width: 100%;
padding: 0.5rem 0.75rem;
border: 1px solid #e0e0e0;
border-radius: 4px;
font-size: 0.9375rem;
font-family: inherit;
}
.search-input:focus {
outline: none;
border-color: #3b82f6;
}
.section-list {
list-style: none;
margin: 0;
padding: 0;
overflow-y: auto;
flex: 1;
}
.section-item {
width: 100%;
text-align: left;
padding: 0.75rem 1rem;
border: none;
border-bottom: 1px solid #f0f0f0;
background: white;
cursor: pointer;
transition: background-color 0.15s;
font-family: inherit;
}
.section-item:hover {
background: #f9fafb;
}
.section-item.active {
background: #eff6ff;
border-left: 3px solid #3b82f6;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.25rem;
}
.section-title {
font-size: 0.9375rem;
font-weight: 500;
color: #1a1a1a;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.section-savings {
font-size: 0.75rem;
font-weight: 600;
color: #10b981;
padding: 0.125rem 0.375rem;
background: #d1fae5;
border-radius: 3px;
white-space: nowrap;
}
.section-savings.negative {
color: #ef4444;
background: #fee2e2;
}
.section-preview {
font-size: 0.8125rem;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.comparison-view {
flex: 1;
overflow: auto;
background: #fafafa;
}
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
padding: 1rem;
height: 100%;
}
.comparison-column {
background: white;
border: 1px solid #e0e0e0;
border-radius: 4px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.comparison-column h2 {
margin: 0;
padding: 1rem;
font-size: 1.125rem;
font-weight: 600;
color: #1a1a1a;
border-bottom: 1px solid #e0e0e0;
background: #fafafa;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
}
.char-count {
font-size: 0.8125rem;
font-weight: 400;
color: #666;
white-space: nowrap;
}
.content-box {
padding: 1rem;
overflow: auto;
flex: 1;
font-size: 0.9375rem;
line-height: 1.6;
}
.content-box pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
font-size: 0.875rem;
color: #333;
}
.empty-state {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
color: #666;
font-size: 0.9375rem;
}
@media (max-width: 768px) {
.comparison-grid {
grid-template-columns: 1fr;
}
.sidebar {
width: 100%;
max-height: 25vh;
}
.main-content {
flex-direction: column;
}
.comparison-column h2 {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.char-count {
font-size: 0.75rem;
}
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M416.9 93.1c-41.1-58.9-122.4-76.3-181.2-38.9L132.5 120c-28.2 17.7-47.6 46.5-53.5 79.3-4.9 27.3-.6 55.5 12.3 80-8.8 13.4-14.9 28.5-17.7 44.2-5.9 33.4 1.8 67.8 21.6 95.4 41.2 58.9 122.4 76.3 181.2 38.9L379.6 392c28.2-17.7 47.6-46.5 53.5-79.3 4.9-27.3.6-55.5-12.3-80 8.8-13.4 14.9-28.4 17.7-44.2 5.8-33.4-1.9-67.8-21.6-95.4" style="fill:#ff3e00"/><path d="M225.6 424.5c-33.3 8.6-68.4-4.4-88-32.6-11.9-16.6-16.5-37.3-13-57.4.6-3.3 1.4-6.5 2.5-9.6l1.9-5.9 5.3 3.9c12.2 9 25.9 15.8 40.4 20.2l3.8 1.2-.4 3.8c-.5 5.4 1 10.9 4.2 15.3 5.9 8.5 16.5 12.4 26.5 9.8 2.2-.6 4.4-1.5 6.3-2.8l103.2-65.8c5.1-3.2 8.6-8.4 9.7-14.4 1.1-6.1-.3-12.3-3.9-17.3-5.9-8.5-16.5-12.4-26.5-9.8-2.2.6-4.4 1.5-6.3 2.8L252 291c-6.5 4.1-13.5 7.2-21 9.2-33.3 8.6-68.4-4.4-88-32.6-11.9-16.6-16.5-37.3-13-57.4 3.5-19.7 15.2-37 32.2-47.7l103.2-65.8c6.5-4.1 13.5-7.2 21-9.2 33.3-8.6 68.4 4.4 88 32.6 11.9 16.6 16.5 37.3 13 57.4-.6 3.3-1.4 6.5-2.5 9.6L383 193l-5.3-3.9c-12.2-9-25.9-15.8-40.4-20.2l-3.8-1.2.4-3.8c.5-5.4-1-10.9-4.2-15.3-5.9-8.5-16.5-12.4-26.5-9.8-2.2.6-4.4 1.5-6.3 2.8l-103.2 65.8c-5.1 3.2-8.6 8.4-9.7 14.4-1.1 6.1.3 12.3 3.9 17.3 5.9 8.5 16.5 12.4 26.5 9.8 2.2-.6 4.4-1.5 6.3-2.8L260 221c6.5-4.1 13.5-7.2 21-9.2 33.3-8.6 68.4 4.4 88 32.6 11.9 16.6 16.5 37.3 13 57.4-3.5 19.7-15.2 37-32.2 47.7l-103.2 65.8c-6.5 4.1-13.6 7.2-21 9.2" style="fill:#fff"/></svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,23 +0,0 @@
You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
## Available Svelte MCP Tools:
### 1. list-sections
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
### 2. get-documentation
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task.
### 3. svelte-autofixer
Analyzes Svelte code and returns issues and suggestions.
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned.
### 4. playground-link
Generates a Svelte Playground link with the provided code.
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project.

View File

@@ -13,10 +13,32 @@ The setup varies based on the version of the MCP you prefer — remote or local
## Usage
To get the most out of the MCP server we recommend including the following prompt in your [`AGENTS.md`](https://agents.md) (or [`CLAUDE.md`](https://docs.claude.com/en/docs/claude-code/memory#claude-md-imports), if using Claude Code. Or [`GEMINI.md`](https://geminicli.com/docs/cli/gemini-md/), if using GEMINI). This will tell the LLM which tools are available and when it's appropriate to use them.
To get the most out of the MCP server we recommend including the following prompt in your [`AGENTS.md`](https://agents.md) (or [`CLAUDE.md`](https://docs.claude.com/en/docs/claude-code/memory#claude-md-imports), if using Claude Code). This will tell the LLM which tools are available and when it's appropriate to use them.
> [!NOTE] This is already setup for you when using `npx sv add mcp`
```md
You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
@include .generated/agents.md
## Available MCP Tools:
### 1. list-sections
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
### 2. get-documentation
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task.
### 3. svelte-autofixer
Analyzes Svelte code and returns issues and suggestions.
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned.
### 4. playground-link
Generates a Svelte Playground link with the provided code.
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project.
```
If your MCP client supports it, we also recommend using the [svelte-task](prompts#svelte-task) prompt to instruct the LLM on the best way to use the MCP server.

View File

@@ -45,27 +45,6 @@ command = "npx"
args = ["-y", "@sveltejs/mcp"]
```
## Copilot CLI
Use the Copilot CLI to interactively add the MCP server:
```bash
/mcp add
```
Alternatively, create or edit `~/.copilot/mcp-config.json` and add the following configuration:
```json
{
"mcpServers": {
"svelte": {
"command": "npx",
"args": ["-y", "@sveltejs/mcp"]
}
}
}
```
## Gemini CLI
To include the local MCP version in Gemini CLI, simply run the following command:
@@ -78,7 +57,7 @@ The `[scope]` must be `user`, `project` or `local`.
## OpenCode
You can automatically configure the MCP server using the [OpenCode plugin](opencode-plugin) (recommended). If you prefer to configure the MCP server manually, run:
Run the command:
```bash
opencode mcp add
@@ -131,12 +110,6 @@ It will open a file with your MCP servers where you can add the following config
## Zed
Install the [Svelte MCP Server extension](https://zed.dev/extensions/svelte-mcp).
<details>
<summary>Configure Manually</summary>
- Open the command palette
- Search and select "agent:open settings"
- In settings panel look for `Model Context Protocol (MCP) Servers`
@@ -154,8 +127,6 @@ It will open a popup with MCP server config where you can add the following conf
}
```
</details>
## Other clients
If we didn't include the MCP client you are using, refer to their documentation for `stdio` servers and use `npx` as the command and `-y @sveltejs/mcp` as the arguments.

View File

@@ -16,8 +16,6 @@ claude mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
You can choose your preferred `scope` (it must be `user`, `project` or `local`) and `name`.
If you prefer you can also install the `svelte` plugin in [the Svelte Claude Code Marketplace](plugin) that will give you both the remote server and useful [skills](skills).
## Claude Desktop
- Open Settings > Connectors
@@ -36,26 +34,6 @@ experimental_use_rmcp_client = true
url = "https://mcp.svelte.dev/mcp"
```
## Copilot CLI
Use the Copilot CLI to interactively add the MCP server:
```bash
/mcp add
```
Alternatively, create or edit `~/.copilot/mcp-config.json` and add the following configuration:
```json
{
"mcpServers": {
"svelte": {
"url": "https://mcp.svelte.dev/mcp"
}
}
}
```
## Gemini CLI
To use the remote MCP server with Gemini CLI, simply run the following command:
@@ -64,11 +42,11 @@ To use the remote MCP server with Gemini CLI, simply run the following command:
gemini mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
```
The `[scope]` must be `user` or `project`.
The `[scope]` must be `user`, `project` or `local`.
## OpenCode
You can automatically configure the MCP server using the [OpenCode plugin](opencode-plugin) (recommended). If you prefer to configure the MCP server manually, run:
Run the command:
```bash
opencode mcp add
@@ -118,27 +96,6 @@ It will open a file with your MCP servers where you can add the following config
}
```
## GitHub Coding Agent
- Open your repository in GitHub
- Go to Settings
- Open Copilot > Coding agent
- Edit the MCP configuration
```json
{
"mcpServers": {
"svelte": {
"type": "http",
"url": "https://mcp.svelte.dev/mcp",
"tools": ["*"]
}
}
}
```
- Click _Save MCP configuration_
## Other clients
If we didn't include the MCP client you are using, refer to their documentation for `remote` servers and use `https://mcp.svelte.dev/mcp` as the URL.

View File

@@ -1,209 +0,0 @@
## svelte-task
This prompt should be used whenever you are asking the model to work on a Svelte-related task. It will instruct the LLM which documentation sections are available, which tools to invoke, when to invoke them, and how to interpret the results.
<details>
<summary>Copy the prompt</summary>
```md
You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool `get-documentation` with one of the following paths. However: before invoking the `get-documentation` tool, try to answer the users query using your own knowledge and the `svelte-autofixer` tool. Be mindful of how many section you request, since it is token-intensive!
<available-docs>
- title: Overview, use_cases: project setup, creating new svelte apps, scaffolding, cli tools, initializing projects, path: cli/overview
- title: Frequently asked questions, use_cases: project setup, initializing new svelte projects, troubleshooting cli installation, package manager configuration, path: cli/faq
- title: sv create, use_cases: project setup, starting new sveltekit app, initializing project, creating from playground, choosing project template, path: cli/sv-create
- title: sv add, use_cases: project setup, adding features to existing projects, integrating tools, testing setup, styling setup, authentication, database setup, deployment adapters, path: cli/sv-add
- title: sv check, use_cases: code quality, ci/cd pipelines, error checking, typescript projects, pre-commit hooks, finding unused css, accessibility auditing, production builds, path: cli/sv-check
- title: sv migrate, use_cases: migration, upgrading svelte versions, upgrading sveltekit versions, modernizing codebase, svelte 3 to 4, svelte 4 to 5, sveltekit 1 to 2, adopting runes, refactoring deprecated apis, path: cli/sv-migrate
- title: devtools-json, use_cases: development setup, chrome devtools integration, browser-based editing, local development workflow, debugging setup, path: cli/devtools-json
- title: drizzle, use_cases: database setup, sql queries, orm integration, data modeling, postgresql, mysql, sqlite, server-side data access, database migrations, type-safe queries, path: cli/drizzle
- title: eslint, use_cases: code quality, linting, error detection, project setup, code standards, team collaboration, typescript projects, path: cli/eslint
- title: lucia, use_cases: authentication, login systems, user management, registration pages, session handling, auth setup, path: cli/lucia
- title: mcp, use_cases: use title and path to estimate use case, path: cli/mcp
- title: mdsvex, use_cases: blog, content sites, markdown rendering, documentation sites, technical writing, cms integration, article pages, path: cli/mdsvex
- title: paraglide, use_cases: internationalization, multi-language sites, i18n, translation, localization, language switching, global apps, multilingual content, path: cli/paraglide
- title: playwright, use_cases: browser testing, e2e testing, integration testing, test automation, quality assurance, ci/cd pipelines, testing user flows, path: cli/playwright
- title: prettier, use_cases: code formatting, project setup, code style consistency, team collaboration, linting configuration, path: cli/prettier
- title: storybook, use_cases: component development, design systems, ui library, isolated component testing, documentation, visual testing, component showcase, path: cli/storybook
- title: sveltekit-adapter, use_cases: deployment, production builds, hosting setup, choosing deployment platform, configuring adapters, static site generation, node server, vercel, cloudflare, netlify, path: cli/sveltekit-adapter
- title: tailwindcss, use_cases: project setup, styling, css framework, rapid prototyping, utility-first css, design systems, responsive design, adding tailwind to svelte, path: cli/tailwind
- title: vitest, use_cases: testing, unit tests, component testing, test setup, quality assurance, ci/cd pipelines, test-driven development, path: cli/vitest
- title: add-on, use_cases: use title and path to estimate use case, path: cli/add-on
- title: Introduction, use_cases: learning sveltekit, project setup, understanding framework basics, choosing between svelte and sveltekit, getting started with full-stack apps, path: kit/introduction
- title: Creating a project, use_cases: project setup, starting new sveltekit app, initial development environment, first-time sveltekit users, scaffolding projects, path: kit/creating-a-project
- title: Project types, use_cases: deployment, project setup, choosing adapters, ssg, spa, ssr, serverless, mobile apps, desktop apps, pwa, offline apps, browser extensions, separate backend, docker containers, path: kit/project-types
- title: Project structure, use_cases: project setup, understanding file structure, organizing code, starting new project, learning sveltekit basics, path: kit/project-structure
- title: Web standards, use_cases: always, any sveltekit project, data fetching, forms, api routes, server-side rendering, deployment to various platforms, path: kit/web-standards
- title: Routing, use_cases: routing, navigation, multi-page apps, project setup, file structure, api endpoints, data loading, layouts, error pages, always, path: kit/routing
- title: Loading data, use_cases: data fetching, api calls, database queries, dynamic routes, page initialization, loading states, authentication checks, ssr data, form data, content rendering, path: kit/load
- title: Form actions, use_cases: forms, user input, data submission, authentication, login systems, user registration, progressive enhancement, validation errors, path: kit/form-actions
- title: Page options, use_cases: prerendering static sites, ssr configuration, spa setup, client-side rendering control, url trailing slash handling, adapter deployment config, build optimization, path: kit/page-options
- title: State management, use_cases: sveltekit, server-side rendering, ssr, state management, authentication, data persistence, load functions, context api, navigation, component lifecycle, path: kit/state-management
- title: Remote functions, use_cases: data fetching, server-side logic, database queries, type-safe client-server communication, forms, user input, mutations, authentication, crud operations, optimistic updates, path: kit/remote-functions
- title: Building your app, use_cases: production builds, deployment preparation, build process optimization, adapter configuration, preview before deployment, path: kit/building-your-app
- title: Adapters, use_cases: deployment, production builds, hosting setup, choosing deployment platform, configuring adapters, path: kit/adapters
- title: Zero-config deployments, use_cases: deployment, production builds, hosting setup, choosing deployment platform, ci/cd configuration, path: kit/adapter-auto
- title: Node servers, use_cases: deployment, production builds, node.js hosting, custom server setup, environment configuration, reverse proxy setup, docker deployment, systemd services, path: kit/adapter-node
- title: Static site generation, use_cases: static site generation, ssg, prerendering, deployment, github pages, spa mode, blogs, documentation sites, marketing sites, path: kit/adapter-static
- title: Single-page apps, use_cases: spa mode, single-page apps, client-only rendering, static hosting, mobile app wrappers, no server-side logic, adapter-static setup, fallback pages, path: kit/single-page-apps
- title: Cloudflare, use_cases: deployment, cloudflare workers, cloudflare pages, hosting setup, production builds, serverless deployment, edge computing, path: kit/adapter-cloudflare
- title: Cloudflare Workers, use_cases: deploying to cloudflare workers, cloudflare workers sites deployment, legacy cloudflare adapter, wrangler configuration, cloudflare platform bindings, path: kit/adapter-cloudflare-workers
- title: Netlify, use_cases: deployment, netlify hosting, production builds, serverless functions, edge functions, static site hosting, path: kit/adapter-netlify
- title: Vercel, use_cases: deployment, vercel hosting, production builds, serverless functions, edge functions, isr, image optimization, environment variables, path: kit/adapter-vercel
- title: Writing adapters, use_cases: custom deployment, building adapters, unsupported platforms, adapter development, custom hosting environments, path: kit/writing-adapters
- title: Advanced routing, use_cases: advanced routing, dynamic routes, file viewers, nested paths, custom 404 pages, url validation, route parameters, multi-level navigation, path: kit/advanced-routing
- title: Hooks, use_cases: authentication, logging, error tracking, request interception, api proxying, custom routing, internationalization, database initialization, middleware logic, session management, path: kit/hooks
- title: Errors, use_cases: error handling, custom error pages, 404 pages, api error responses, production error logging, error tracking, type-safe errors, path: kit/errors
- title: Link options, use_cases: routing, navigation, multi-page apps, performance optimization, link preloading, forms with get method, search functionality, focus management, scroll behavior, path: kit/link-options
- title: Service workers, use_cases: offline support, pwa, caching strategies, performance optimization, precaching assets, network resilience, progressive web apps, path: kit/service-workers
- title: Server-only modules, use_cases: api keys, environment variables, sensitive data protection, backend security, preventing data leaks, server-side code isolation, path: kit/server-only-modules
- title: Snapshots, use_cases: forms, user input, preserving form data, multi-step forms, navigation state, preventing data loss, textarea content, input fields, comment systems, surveys, path: kit/snapshots
- title: Shallow routing, use_cases: modals, dialogs, image galleries, overlays, history-driven ui, mobile-friendly navigation, photo viewers, lightboxes, drawer menus, path: kit/shallow-routing
- title: Observability, use_cases: performance monitoring, debugging, observability, tracing requests, production diagnostics, analyzing slow requests, finding bottlenecks, monitoring server-side operations, path: kit/observability
- title: Packaging, use_cases: building component libraries, publishing npm packages, creating reusable svelte components, library development, package distribution, path: kit/packaging
- title: Auth, use_cases: authentication, login systems, user management, session handling, jwt tokens, protected routes, user credentials, authorization checks, path: kit/auth
- title: Performance, use_cases: performance optimization, slow loading pages, production deployment, debugging performance issues, reducing bundle size, improving load times, path: kit/performance
- title: Icons, use_cases: icons, ui components, styling, css frameworks, tailwind, unocss, performance optimization, dependency management, path: kit/icons
- title: Images, use_cases: image optimization, responsive images, performance, hero images, product photos, galleries, cms integration, cdn setup, asset management, path: kit/images
- title: Accessibility, use_cases: always, any sveltekit project, screen reader support, keyboard navigation, multi-page apps, client-side routing, internationalization, multilingual sites, path: kit/accessibility
- title: SEO, use_cases: seo optimization, search engine ranking, content sites, blogs, marketing sites, public-facing apps, sitemaps, amp pages, meta tags, performance optimization, path: kit/seo
- title: Frequently asked questions, use_cases: troubleshooting package imports, library compatibility issues, client-side code execution, external api integration, middleware setup, database configuration, view transitions, yarn configuration, path: kit/faq
- title: Integrations, use_cases: project setup, css preprocessors, postcss, scss, sass, less, stylus, typescript setup, adding integrations, tailwind, testing, auth, linting, formatting, path: kit/integrations
- title: Breakpoint Debugging, use_cases: debugging, breakpoints, development workflow, troubleshooting issues, vscode setup, ide configuration, inspecting code execution, path: kit/debugging
- title: Migrating to SvelteKit v2, use_cases: migration, upgrading from sveltekit 1 to 2, breaking changes, version updates, path: kit/migrating-to-sveltekit-2
- title: Migrating from Sapper, use_cases: migrating from sapper, upgrading legacy projects, sapper to sveltekit conversion, project modernization, path: kit/migrating
- title: Additional resources, use_cases: troubleshooting, getting help, finding examples, learning sveltekit, project templates, common issues, community support, path: kit/additional-resources
- title: Glossary, use_cases: rendering strategies, performance optimization, deployment configuration, seo requirements, static sites, spas, server-side rendering, prerendering, edge deployment, pwa development, path: kit/glossary
- title: @sveltejs/kit, use_cases: forms, form actions, server-side validation, form submission, error handling, redirects, json responses, http errors, server utilities, path: kit/@sveltejs-kit
- title: @sveltejs/kit/hooks, use_cases: middleware, request processing, authentication chains, logging, multiple hooks, request/response transformation, path: kit/@sveltejs-kit-hooks
- title: @sveltejs/kit/node/polyfills, use_cases: node.js environments, custom servers, non-standard runtimes, ssr setup, web api compatibility, polyfill requirements, path: kit/@sveltejs-kit-node-polyfills
- title: @sveltejs/kit/node, use_cases: node.js adapter, custom server setup, http integration, streaming files, node deployment, server-side rendering with node, path: kit/@sveltejs-kit-node
- title: @sveltejs/kit/vite, use_cases: project setup, vite configuration, initial sveltekit setup, build tooling, path: kit/@sveltejs-kit-vite
- title: $app/environment, use_cases: always, conditional logic, client-side code, server-side code, build-time logic, prerendering, development vs production, environment detection, path: kit/$app-environment
- title: $app/forms, use_cases: forms, user input, data submission, progressive enhancement, custom form handling, form validation, path: kit/$app-forms
- title: $app/navigation, use_cases: routing, navigation, multi-page apps, programmatic navigation, data reloading, preloading, shallow routing, navigation lifecycle, scroll handling, view transitions, path: kit/$app-navigation
- title: $app/paths, use_cases: static assets, images, fonts, public files, base path configuration, subdirectory deployment, cdn setup, asset urls, links, navigation, path: kit/$app-paths
- title: $app/server, use_cases: remote functions, server-side logic, data fetching, form handling, api endpoints, client-server communication, prerendering, file reading, batch queries, path: kit/$app-server
- title: $app/state, use_cases: routing, navigation, multi-page apps, loading states, url parameters, form handling, error states, version updates, page metadata, shallow routing, path: kit/$app-state
- title: $app/stores, use_cases: legacy projects, sveltekit pre-2.12, migration from stores to runes, maintaining older codebases, accessing page data, navigation state, app version updates, path: kit/$app-stores
- title: $app/types, use_cases: routing, navigation, type safety, route parameters, dynamic routes, link generation, pathname validation, multi-page apps, path: kit/$app-types
- title: $env/dynamic/private, use_cases: api keys, secrets management, server-side config, environment variables, backend logic, deployment-specific settings, private data handling, path: kit/$env-dynamic-private
- title: $env/dynamic/public, use_cases: environment variables, client-side config, runtime configuration, public api keys, deployment-specific settings, multi-environment apps, path: kit/$env-dynamic-public
- title: $env/static/private, use_cases: server-side api keys, backend secrets, database credentials, private configuration, build-time optimization, server endpoints, authentication tokens, path: kit/$env-static-private
- title: $env/static/public, use_cases: environment variables, public config, client-side data, api endpoints, build-time configuration, public constants, path: kit/$env-static-public
- title: $lib, use_cases: project setup, component organization, importing shared components, reusable ui elements, code structure, path: kit/$lib
- title: $service-worker, use_cases: offline support, pwa, service workers, caching strategies, progressive web apps, offline-first apps, path: kit/$service-worker
- title: Configuration, use_cases: project setup, configuration, adapters, deployment, build settings, environment variables, routing customization, prerendering, csp security, csrf protection, path configuration, typescript setup, path: kit/configuration
- title: Command Line Interface, use_cases: project setup, typescript configuration, generated types, ./$types imports, initial project configuration, path: kit/cli
- title: Types, use_cases: typescript, type safety, route parameters, api endpoints, load functions, form actions, generated types, jsconfig setup, path: kit/types
- title: Overview, use_cases: use title and path to estimate use case, path: mcp/overview
- title: Local setup, use_cases: use title and path to estimate use case, path: mcp/local-setup
- title: Remote setup, use_cases: use title and path to estimate use case, path: mcp/remote-setup
- title: Tools, use_cases: use title and path to estimate use case, path: mcp/tools
- title: Resources, use_cases: use title and path to estimate use case, path: mcp/resources
- title: Prompts, use_cases: use title and path to estimate use case, path: mcp/prompts
- title: Overview, use_cases: use title and path to estimate use case, path: mcp/plugin
- title: Skill, use_cases: use title and path to estimate use case, path: mcp/skill
- title: Subagent, use_cases: use title and path to estimate use case, path: mcp/subagent
- title: Overview, use_cases: use title and path to estimate use case, path: mcp/opencode-plugin
- title: Subagent, use_cases: use title and path to estimate use case, path: mcp/opencode-subagent
- title: Overview, use_cases: always, any svelte project, getting started, learning svelte, introduction, project setup, understanding framework basics, path: svelte/overview
- title: Getting started, use_cases: project setup, starting new svelte project, initial installation, choosing between sveltekit and vite, editor configuration, path: svelte/getting-started
- title: .svelte files, use_cases: always, any svelte project, component creation, project setup, learning svelte basics, path: svelte/svelte-files
- title: .svelte.js and .svelte.ts files, use_cases: shared reactive state, reusable reactive logic, state management across components, global stores, custom reactive utilities, path: svelte/svelte-js-files
- title: What are runes?, use_cases: always, any svelte 5 project, understanding core syntax, learning svelte 5, migration from svelte 4, path: svelte/what-are-runes
- title: $state, use_cases: always, any svelte project, core reactivity, state management, counters, forms, todo apps, interactive ui, data updates, class-based components, path: svelte/$state
- title: $derived, use_cases: always, any svelte project, computed values, reactive calculations, derived data, transforming state, dependent values, path: svelte/$derived
- title: $effect, use_cases: canvas drawing, third-party library integration, dom manipulation, side effects, intervals, timers, network requests, analytics tracking, path: svelte/$effect
- title: $props, use_cases: always, any svelte project, passing data to components, component communication, reusable components, component props, path: svelte/$props
- title: $bindable, use_cases: forms, user input, two-way data binding, custom input components, parent-child communication, reusable form fields, path: svelte/$bindable
- title: $inspect, use_cases: debugging, development, tracking state changes, reactive state monitoring, troubleshooting reactivity issues, path: svelte/$inspect
- title: $host, use_cases: custom elements, web components, dispatching custom events, component library, framework-agnostic components, path: svelte/$host
- title: Basic markup, use_cases: always, any svelte project, basic markup, html templating, component structure, attributes, events, props, text rendering, path: svelte/basic-markup
- title: {#if ...}, use_cases: always, conditional rendering, showing/hiding content, dynamic ui, user permissions, loading states, error handling, form validation, path: svelte/if
- title: {#each ...}, use_cases: always, lists, arrays, iteration, product listings, todos, tables, grids, dynamic content, shopping carts, user lists, comments, feeds, path: svelte/each
- title: {#key ...}, use_cases: animations, transitions, component reinitialization, forcing component remount, value-based ui updates, resetting component state, path: svelte/key
- title: {#await ...}, use_cases: async data fetching, api calls, loading states, promises, error handling, lazy loading components, dynamic imports, path: svelte/await
- title: {#snippet ...}, use_cases: reusable markup, component composition, passing content to components, table rows, list items, conditional rendering, reducing duplication, path: svelte/snippet
- title: {@render ...}, use_cases: reusable ui patterns, component composition, conditional rendering, fallback content, layout components, slot alternatives, template reuse, path: svelte/@render
- title: {@html ...}, use_cases: rendering html strings, cms content, rich text editors, markdown to html, blog posts, wysiwyg output, sanitized html injection, dynamic html content, path: svelte/@html
- title: {@attach ...}, use_cases: tooltips, popovers, dom manipulation, third-party libraries, canvas drawing, element lifecycle, interactive ui, custom directives, wrapper components, path: svelte/@attach
- title: {@const ...}, use_cases: computed values in loops, derived calculations in blocks, local variables in each iterations, complex list rendering, path: svelte/@const
- title: {@debug ...}, use_cases: debugging, development, troubleshooting, tracking state changes, monitoring variables, reactive data inspection, path: svelte/@debug
- title: bind:, use_cases: forms, user input, two-way data binding, interactive ui, media players, file uploads, checkboxes, radio buttons, select dropdowns, contenteditable, dimension tracking, path: svelte/bind
- title: use:, use_cases: custom directives, dom manipulation, third-party library integration, tooltips, click outside, gestures, focus management, element lifecycle hooks, path: svelte/use
- title: transition:, use_cases: animations, interactive ui, modals, dropdowns, notifications, conditional content, show/hide elements, smooth state changes, path: svelte/transition
- title: in: and out:, use_cases: animation, transitions, interactive ui, conditional rendering, independent enter/exit effects, modals, tooltips, notifications, path: svelte/in-and-out
- title: animate:, use_cases: sortable lists, drag and drop, reorderable items, todo lists, kanban boards, playlist editors, priority queues, animated list reordering, path: svelte/animate
- title: style:, use_cases: dynamic styling, conditional styles, theming, dark mode, responsive design, interactive ui, component styling, path: svelte/style
- title: class, use_cases: always, conditional styling, dynamic classes, tailwind css, component styling, reusable components, responsive design, path: svelte/class
- title: await, use_cases: async data fetching, loading states, server-side rendering, awaiting promises in components, async validation, concurrent data loading, path: svelte/await-expressions
- title: Scoped styles, use_cases: always, styling components, scoped css, component-specific styles, preventing style conflicts, animations, keyframes, path: svelte/scoped-styles
- title: Global styles, use_cases: global styles, third-party libraries, css resets, animations, styling body/html, overriding component styles, shared keyframes, base styles, path: svelte/global-styles
- title: Custom properties, use_cases: theming, custom styling, reusable components, design systems, dynamic colors, component libraries, ui customization, path: svelte/custom-properties
- title: Nested <style> elements, use_cases: component styling, scoped styles, dynamic styles, conditional styling, nested style tags, custom styling logic, path: svelte/nested-style-elements
- title: <svelte:boundary>, use_cases: error handling, async data loading, loading states, error recovery, flaky components, error reporting, resilient ui, path: svelte/svelte-boundary
- title: <svelte:window>, use_cases: keyboard shortcuts, scroll tracking, window resize handling, responsive layouts, online/offline detection, viewport dimensions, global event listeners, path: svelte/svelte-window
- title: <svelte:document>, use_cases: document events, visibility tracking, fullscreen detection, pointer lock, focus management, document-level interactions, path: svelte/svelte-document
- title: <svelte:body>, use_cases: mouse tracking, hover effects, cursor interactions, global body events, drag and drop, custom cursors, interactive backgrounds, body-level actions, path: svelte/svelte-body
- title: <svelte:head>, use_cases: seo optimization, page titles, meta tags, social media sharing, dynamic head content, multi-page apps, blog posts, product pages, path: svelte/svelte-head
- title: <svelte:element>, use_cases: dynamic content, cms integration, user-generated content, configurable ui, runtime element selection, flexible components, path: svelte/svelte-element
- title: <svelte:options>, use_cases: migration, custom elements, web components, legacy mode compatibility, runes mode setup, svg components, mathml components, css injection control, path: svelte/svelte-options
- title: Stores, use_cases: shared state, cross-component data, reactive values, async data streams, manual control over updates, rxjs integration, extracting logic, path: svelte/stores
- title: Context, use_cases: shared state, avoiding prop drilling, component communication, theme providers, user context, authentication state, configuration sharing, deeply nested components, path: svelte/context
- title: Lifecycle hooks, use_cases: component initialization, cleanup tasks, timers, subscriptions, dom measurements, chat windows, autoscroll features, migration from svelte 4, path: svelte/lifecycle-hooks
- title: Imperative component API, use_cases: project setup, client-side rendering, server-side rendering, ssr, hydration, testing, programmatic component creation, tooltips, dynamic mounting, path: svelte/imperative-component-api
- title: Hydratable data, use_cases: use title and path to estimate use case, path: svelte/hydratable
- title: Testing, use_cases: testing, quality assurance, unit tests, integration tests, component tests, e2e tests, vitest setup, playwright setup, test automation, path: svelte/testing
- title: TypeScript, use_cases: typescript setup, type safety, component props typing, generic components, wrapper components, dom type augmentation, project configuration, path: svelte/typescript
- title: Custom elements, use_cases: web components, custom elements, component library, design system, framework-agnostic components, embedding svelte in non-svelte apps, shadow dom, path: svelte/custom-elements
- title: Svelte 4 migration guide, use_cases: upgrading svelte 3 to 4, version migration, updating dependencies, breaking changes, legacy project maintenance, path: svelte/v4-migration-guide
- title: Svelte 5 migration guide, use_cases: migrating from svelte 4 to 5, upgrading projects, learning svelte 5 syntax changes, runes migration, event handler updates, path: svelte/v5-migration-guide
- title: Frequently asked questions, use_cases: getting started, learning svelte, beginner setup, project initialization, vs code setup, formatting, testing, routing, mobile apps, troubleshooting, community support, path: svelte/faq
- title: svelte, use_cases: migration from svelte 4 to 5, upgrading legacy code, component lifecycle hooks, context api, mounting components, event dispatchers, typescript component types, path: svelte/svelte
- title: svelte/action, use_cases: typescript types, actions, use directive, dom manipulation, element lifecycle, custom behaviors, third-party library integration, path: svelte/svelte-action
- title: svelte/animate, use_cases: animated lists, sortable items, drag and drop, reordering elements, todo lists, kanban boards, playlist management, smooth position transitions, path: svelte/svelte-animate
- title: svelte/attachments, use_cases: library development, component libraries, programmatic element manipulation, migrating from actions to attachments, spreading props onto elements, path: svelte/svelte-attachments
- title: svelte/compiler, use_cases: build tools, custom compilers, ast manipulation, preprocessors, code transformation, migration scripts, syntax analysis, bundler plugins, dev tools, path: svelte/svelte-compiler
- title: svelte/easing, use_cases: animations, transitions, custom easing, smooth motion, interactive ui, modals, dropdowns, carousels, page transitions, scroll effects, path: svelte/svelte-easing
- title: svelte/events, use_cases: window events, document events, global event listeners, event delegation, programmatic event handling, cleanup functions, media queries, path: svelte/svelte-events
- title: svelte/legacy, use_cases: migration from svelte 4 to svelte 5, upgrading legacy code, event modifiers, class components, imperative component instantiation, path: svelte/svelte-legacy
- title: svelte/motion, use_cases: animation, smooth transitions, interactive ui, sliders, counters, physics-based motion, drag gestures, accessibility, reduced motion, path: svelte/svelte-motion
- title: svelte/reactivity/window, use_cases: responsive design, viewport tracking, scroll effects, window resize handling, online/offline detection, zoom level tracking, path: svelte/svelte-reactivity-window
- title: svelte/reactivity, use_cases: reactive data structures, state management with maps/sets, game boards, selection tracking, url manipulation, query params, real-time clocks, media queries, responsive design, path: svelte/svelte-reactivity
- title: svelte/server, use_cases: server-side rendering, ssr, static site generation, seo optimization, initial page load, pre-rendering, node.js server, custom server setup, path: svelte/svelte-server
- title: svelte/store, use_cases: state management, shared data, reactive stores, cross-component communication, global state, computed values, data synchronization, legacy svelte projects, path: svelte/svelte-store
- title: svelte/transition, use_cases: animations, transitions, interactive ui, modals, dropdowns, tooltips, notifications, svg animations, list animations, page transitions, path: svelte/svelte-transition
- title: Compiler errors, use_cases: animation, transitions, keyed each blocks, list animations, path: svelte/compiler-errors
- title: Compiler warnings, use_cases: accessibility, a11y compliance, wcag standards, screen readers, keyboard navigation, aria attributes, semantic html, interactive elements, path: svelte/compiler-warnings
- title: Runtime errors, use_cases: debugging errors, error handling, troubleshooting runtime issues, migration to svelte 5, component binding, effects and reactivity, path: svelte/runtime-errors
- title: Runtime warnings, use_cases: debugging state proxies, console logging reactive values, inspecting state changes, development troubleshooting, path: svelte/runtime-warnings
- title: Overview, use_cases: migrating from svelte 3/4 to svelte 5, maintaining legacy components, understanding deprecated features, gradual upgrade process, path: svelte/legacy-overview
- title: Reactive let/var declarations, use_cases: migration, legacy svelte projects, upgrading from svelte 4, understanding old reactivity, maintaining existing code, learning runes differences, path: svelte/legacy-let
- title: Reactive $: statements, use_cases: legacy mode, migration from svelte 4, reactive statements, computed values, derived state, side effects, path: svelte/legacy-reactive-assignments
- title: export let, use_cases: legacy mode, migration from svelte 4, maintaining older projects, component props without runes, exporting component methods, renaming reserved word props, path: svelte/legacy-export-let
- title: $$props and $$restProps, use_cases: legacy mode migration, component wrappers, prop forwarding, button components, reusable ui components, spreading props to child elements, path: svelte/legacy-$$props-and-$$restProps
- title: on:, use_cases: legacy mode, event handling, button clicks, forms, user interactions, component communication, event forwarding, event modifiers, path: svelte/legacy-on
- title: <slot>, use_cases: legacy mode, migrating from svelte 4, component composition, reusable components, passing content to components, modals, layouts, wrappers, path: svelte/legacy-slots
- title: $$slots, use_cases: legacy mode, conditional slot rendering, optional content sections, checking if slots provided, migrating from legacy to runes, path: svelte/legacy-$$slots
- title: <svelte:fragment>, use_cases: named slots, component composition, layout systems, avoiding wrapper divs, legacy svelte projects, slot content organization, path: svelte/legacy-svelte-fragment
- title: <svelte:component>, use_cases: dynamic components, component switching, conditional rendering, legacy mode migration, tabbed interfaces, multi-step forms, path: svelte/legacy-svelte-component
- title: <svelte:self>, use_cases: recursive components, tree structures, nested menus, file explorers, comment threads, hierarchical data, path: svelte/legacy-svelte-self
- title: Imperative component API, use_cases: migration from svelte 3/4 to 5, legacy component api, maintaining old projects, understanding deprecated patterns, path: svelte/legacy-component-api
</available-docs>
These are the available documentation sections that `list-sections` will return, you do not need to call it again.
Every time you write a Svelte component or a Svelte module you MUST invoke the `svelte-autofixer` tool providing the code. The tool will return a list of issues or suggestions. If there are any issues or suggestions you MUST fix them and call the tool again with the updated code. You MUST keep doing this until the tool returns no issues or suggestions. Only then you can return the code to the user.
This is the task you will work on:
<task>
[YOUR TASK HERE]
</task>
If you are not writing the code into a file, once you have the final version of the code ask the user if it wants to generate a playground link to quickly check the code in it and if it answer yes call the `playground-link` tool and return the url to the user nicely formatted. The playground link MUST be generated only once you have the final version of the code and you are ready to share it, it MUST include an entry point file called `App.svelte` where the main component should live. If you have multiple files to include in the playground link you can include them all at the root.
```
</details>

View File

@@ -4,4 +4,202 @@ title: Prompts
This is the list of available prompts provided by the MCP server. Prompts are selected by the user and are sent as a user message. They can be useful to write repetitive instructions for the LLM on how to properly use the MCP server.
@include .generated/prompts.md
## svelte-task
This prompt should be used whenever you are asking the model to work on a Svelte-related task. It will instruct the LLM which documentation sections are available, which tools to invoke, when to invoke them, and how to interpret the results.
<details>
<summary>Copy the prompt</summary>
```md
You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool `get_documentation` with one of the following paths:
<available-docs>
- title: Overview, use_cases: project setup, creating new svelte apps, scaffolding, cli tools, initializing projects, path: cli/overview
- title: Frequently asked questions, use_cases: project setup, initializing new svelte projects, troubleshooting cli installation, package manager configuration, path: cli/faq
- title: sv create, use_cases: project setup, starting new sveltekit app, initializing project, creating from playground, choosing project template, path: cli/sv-create
- title: sv add, use_cases: project setup, adding features to existing projects, integrating tools, testing setup, styling setup, authentication, database setup, deployment adapters, path: cli/sv-add
- title: sv check, use_cases: code quality, ci/cd pipelines, error checking, typescript projects, pre-commit hooks, finding unused css, accessibility auditing, production builds, path: cli/sv-check
- title: sv migrate, use_cases: migration, upgrading svelte versions, upgrading sveltekit versions, modernizing codebase, svelte 3 to 4, svelte 4 to 5, sveltekit 1 to 2, adopting runes, refactoring deprecated apis, path: cli/sv-migrate
- title: devtools-json, use_cases: development setup, chrome devtools integration, browser-based editing, local development workflow, debugging setup, path: cli/devtools-json
- title: drizzle, use_cases: database setup, sql queries, orm integration, data modeling, postgresql, mysql, sqlite, server-side data access, database migrations, type-safe queries, path: cli/drizzle
- title: eslint, use_cases: code quality, linting, error detection, project setup, code standards, team collaboration, typescript projects, path: cli/eslint
- title: lucia, use_cases: authentication, login systems, user management, registration pages, session handling, auth setup, path: cli/lucia
- title: mdsvex, use_cases: blog, content sites, markdown rendering, documentation sites, technical writing, cms integration, article pages, path: cli/mdsvex
- title: paraglide, use_cases: internationalization, multi-language sites, i18n, translation, localization, language switching, global apps, multilingual content, path: cli/paraglide
- title: playwright, use_cases: browser testing, e2e testing, integration testing, test automation, quality assurance, ci/cd pipelines, testing user flows, path: cli/playwright
- title: prettier, use_cases: code formatting, project setup, code style consistency, team collaboration, linting configuration, path: cli/prettier
- title: storybook, use_cases: component development, design systems, ui library, isolated component testing, documentation, visual testing, component showcase, path: cli/storybook
- title: sveltekit-adapter, use_cases: deployment, production builds, hosting setup, choosing deployment platform, configuring adapters, static site generation, node server, vercel, cloudflare, netlify, path: cli/sveltekit-adapter
- title: tailwindcss, use_cases: project setup, styling, css framework, rapid prototyping, utility-first css, design systems, responsive design, adding tailwind to svelte, path: cli/tailwind
- title: vitest, use_cases: testing, unit tests, component testing, test setup, quality assurance, ci/cd pipelines, test-driven development, path: cli/vitest
- title: Introduction, use_cases: learning sveltekit, project setup, understanding framework basics, choosing between svelte and sveltekit, getting started with full-stack apps, path: kit/introduction
- title: Creating a project, use_cases: project setup, starting new sveltekit app, initial development environment, first-time sveltekit users, scaffolding projects, path: kit/creating-a-project
- title: Project types, use_cases: deployment, project setup, choosing adapters, ssg, spa, ssr, serverless, mobile apps, desktop apps, pwa, offline apps, browser extensions, separate backend, docker containers, path: kit/project-types
- title: Project structure, use_cases: project setup, understanding file structure, organizing code, starting new project, learning sveltekit basics, path: kit/project-structure
- title: Web standards, use_cases: always, any sveltekit project, data fetching, forms, api routes, server-side rendering, deployment to various platforms, path: kit/web-standards
- title: Routing, use_cases: routing, navigation, multi-page apps, project setup, file structure, api endpoints, data loading, layouts, error pages, always, path: kit/routing
- title: Loading data, use_cases: data fetching, api calls, database queries, dynamic routes, page initialization, loading states, authentication checks, ssr data, form data, content rendering, path: kit/load
- title: Form actions, use_cases: forms, user input, data submission, authentication, login systems, user registration, progressive enhancement, validation errors, path: kit/form-actions
- title: Page options, use_cases: prerendering static sites, ssr configuration, spa setup, client-side rendering control, url trailing slash handling, adapter deployment config, build optimization, path: kit/page-options
- title: State management, use_cases: sveltekit, server-side rendering, ssr, state management, authentication, data persistence, load functions, context api, navigation, component lifecycle, path: kit/state-management
- title: Remote functions, use_cases: data fetching, server-side logic, database queries, type-safe client-server communication, forms, user input, mutations, authentication, crud operations, optimistic updates, path: kit/remote-functions
- title: Building your app, use_cases: production builds, deployment preparation, build process optimization, adapter configuration, preview before deployment, path: kit/building-your-app
- title: Adapters, use_cases: deployment, production builds, hosting setup, choosing deployment platform, configuring adapters, path: kit/adapters
- title: Zero-config deployments, use_cases: deployment, production builds, hosting setup, choosing deployment platform, ci/cd configuration, path: kit/adapter-auto
- title: Node servers, use_cases: deployment, production builds, node.js hosting, custom server setup, environment configuration, reverse proxy setup, docker deployment, systemd services, path: kit/adapter-node
- title: Static site generation, use_cases: static site generation, ssg, prerendering, deployment, github pages, spa mode, blogs, documentation sites, marketing sites, path: kit/adapter-static
- title: Single-page apps, use_cases: spa mode, single-page apps, client-only rendering, static hosting, mobile app wrappers, no server-side logic, adapter-static setup, fallback pages, path: kit/single-page-apps
- title: Cloudflare, use_cases: deployment, cloudflare workers, cloudflare pages, hosting setup, production builds, serverless deployment, edge computing, path: kit/adapter-cloudflare
- title: Cloudflare Workers, use_cases: deploying to cloudflare workers, cloudflare workers sites deployment, legacy cloudflare adapter, wrangler configuration, cloudflare platform bindings, path: kit/adapter-cloudflare-workers
- title: Netlify, use_cases: deployment, netlify hosting, production builds, serverless functions, edge functions, static site hosting, path: kit/adapter-netlify
- title: Vercel, use_cases: deployment, vercel hosting, production builds, serverless functions, edge functions, isr, image optimization, environment variables, path: kit/adapter-vercel
- title: Writing adapters, use_cases: custom deployment, building adapters, unsupported platforms, adapter development, custom hosting environments, path: kit/writing-adapters
- title: Advanced routing, use_cases: advanced routing, dynamic routes, file viewers, nested paths, custom 404 pages, url validation, route parameters, multi-level navigation, path: kit/advanced-routing
- title: Hooks, use_cases: authentication, logging, error tracking, request interception, api proxying, custom routing, internationalization, database initialization, middleware logic, session management, path: kit/hooks
- title: Errors, use_cases: error handling, custom error pages, 404 pages, api error responses, production error logging, error tracking, type-safe errors, path: kit/errors
- title: Link options, use_cases: routing, navigation, multi-page apps, performance optimization, link preloading, forms with get method, search functionality, focus management, scroll behavior, path: kit/link-options
- title: Service workers, use_cases: offline support, pwa, caching strategies, performance optimization, precaching assets, network resilience, progressive web apps, path: kit/service-workers
- title: Server-only modules, use_cases: api keys, environment variables, sensitive data protection, backend security, preventing data leaks, server-side code isolation, path: kit/server-only-modules
- title: Snapshots, use_cases: forms, user input, preserving form data, multi-step forms, navigation state, preventing data loss, textarea content, input fields, comment systems, surveys, path: kit/snapshots
- title: Shallow routing, use_cases: modals, dialogs, image galleries, overlays, history-driven ui, mobile-friendly navigation, photo viewers, lightboxes, drawer menus, path: kit/shallow-routing
- title: Observability, use_cases: performance monitoring, debugging, observability, tracing requests, production diagnostics, analyzing slow requests, finding bottlenecks, monitoring server-side operations, path: kit/observability
- title: Packaging, use_cases: building component libraries, publishing npm packages, creating reusable svelte components, library development, package distribution, path: kit/packaging
- title: Auth, use_cases: authentication, login systems, user management, session handling, jwt tokens, protected routes, user credentials, authorization checks, path: kit/auth
- title: Performance, use_cases: performance optimization, slow loading pages, production deployment, debugging performance issues, reducing bundle size, improving load times, path: kit/performance
- title: Icons, use_cases: icons, ui components, styling, css frameworks, tailwind, unocss, performance optimization, dependency management, path: kit/icons
- title: Images, use_cases: image optimization, responsive images, performance, hero images, product photos, galleries, cms integration, cdn setup, asset management, path: kit/images
- title: Accessibility, use_cases: always, any sveltekit project, screen reader support, keyboard navigation, multi-page apps, client-side routing, internationalization, multilingual sites, path: kit/accessibility
- title: SEO, use_cases: seo optimization, search engine ranking, content sites, blogs, marketing sites, public-facing apps, sitemaps, amp pages, meta tags, performance optimization, path: kit/seo
- title: Frequently asked questions, use_cases: troubleshooting package imports, library compatibility issues, client-side code execution, external api integration, middleware setup, database configuration, view transitions, yarn configuration, path: kit/faq
- title: Integrations, use_cases: project setup, css preprocessors, postcss, scss, sass, less, stylus, typescript setup, adding integrations, tailwind, testing, auth, linting, formatting, path: kit/integrations
- title: Breakpoint Debugging, use_cases: debugging, breakpoints, development workflow, troubleshooting issues, vscode setup, ide configuration, inspecting code execution, path: kit/debugging
- title: Migrating to SvelteKit v2, use_cases: migration, upgrading from sveltekit 1 to 2, breaking changes, version updates, path: kit/migrating-to-sveltekit-2
- title: Migrating from Sapper, use_cases: migrating from sapper, upgrading legacy projects, sapper to sveltekit conversion, project modernization, path: kit/migrating
- title: Additional resources, use_cases: troubleshooting, getting help, finding examples, learning sveltekit, project templates, common issues, community support, path: kit/additional-resources
- title: Glossary, use_cases: rendering strategies, performance optimization, deployment configuration, seo requirements, static sites, spas, server-side rendering, prerendering, edge deployment, pwa development, path: kit/glossary
- title: @sveltejs/kit, use_cases: forms, form actions, server-side validation, form submission, error handling, redirects, json responses, http errors, server utilities, path: kit/@sveltejs-kit
- title: @sveltejs/kit/hooks, use_cases: middleware, request processing, authentication chains, logging, multiple hooks, request/response transformation, path: kit/@sveltejs-kit-hooks
- title: @sveltejs/kit/node/polyfills, use_cases: node.js environments, custom servers, non-standard runtimes, ssr setup, web api compatibility, polyfill requirements, path: kit/@sveltejs-kit-node-polyfills
- title: @sveltejs/kit/node, use_cases: node.js adapter, custom server setup, http integration, streaming files, node deployment, server-side rendering with node, path: kit/@sveltejs-kit-node
- title: @sveltejs/kit/vite, use_cases: project setup, vite configuration, initial sveltekit setup, build tooling, path: kit/@sveltejs-kit-vite
- title: $app/environment, use_cases: always, conditional logic, client-side code, server-side code, build-time logic, prerendering, development vs production, environment detection, path: kit/$app-environment
- title: $app/forms, use_cases: forms, user input, data submission, progressive enhancement, custom form handling, form validation, path: kit/$app-forms
- title: $app/navigation, use_cases: routing, navigation, multi-page apps, programmatic navigation, data reloading, preloading, shallow routing, navigation lifecycle, scroll handling, view transitions, path: kit/$app-navigation
- title: $app/paths, use_cases: static assets, images, fonts, public files, base path configuration, subdirectory deployment, cdn setup, asset urls, links, navigation, path: kit/$app-paths
- title: $app/server, use_cases: remote functions, server-side logic, data fetching, form handling, api endpoints, client-server communication, prerendering, file reading, batch queries, path: kit/$app-server
- title: $app/state, use_cases: routing, navigation, multi-page apps, loading states, url parameters, form handling, error states, version updates, page metadata, shallow routing, path: kit/$app-state
- title: $app/stores, use_cases: legacy projects, sveltekit pre-2.12, migration from stores to runes, maintaining older codebases, accessing page data, navigation state, app version updates, path: kit/$app-stores
- title: $app/types, use_cases: routing, navigation, type safety, route parameters, dynamic routes, link generation, pathname validation, multi-page apps, path: kit/$app-types
- title: $env/dynamic/private, use_cases: api keys, secrets management, server-side config, environment variables, backend logic, deployment-specific settings, private data handling, path: kit/$env-dynamic-private
- title: $env/dynamic/public, use_cases: environment variables, client-side config, runtime configuration, public api keys, deployment-specific settings, multi-environment apps, path: kit/$env-dynamic-public
- title: $env/static/private, use_cases: server-side api keys, backend secrets, database credentials, private configuration, build-time optimization, server endpoints, authentication tokens, path: kit/$env-static-private
- title: $env/static/public, use_cases: environment variables, public config, client-side data, api endpoints, build-time configuration, public constants, path: kit/$env-static-public
- title: $lib, use_cases: project setup, component organization, importing shared components, reusable ui elements, code structure, path: kit/$lib
- title: $service-worker, use_cases: offline support, pwa, service workers, caching strategies, progressive web apps, offline-first apps, path: kit/$service-worker
- title: Configuration, use_cases: project setup, configuration, adapters, deployment, build settings, environment variables, routing customization, prerendering, csp security, csrf protection, path configuration, typescript setup, path: kit/configuration
- title: Command Line Interface, use_cases: project setup, typescript configuration, generated types, ./$types imports, initial project configuration, path: kit/cli
- title: Types, use_cases: typescript, type safety, route parameters, api endpoints, load functions, form actions, generated types, jsconfig setup, path: kit/types
- title: Overview, use_cases: use title and path to estimate use case, path: mcp/overview
- title: Local setup, use_cases: use title and path to estimate use case, path: mcp/local-setup
- title: Remote setup, use_cases: use title and path to estimate use case, path: mcp/remote-setup
- title: Tools, use_cases: use title and path to estimate use case, path: mcp/tools
- title: Resources, use_cases: use title and path to estimate use case, path: mcp/resources
- title: Prompts, use_cases: use title and path to estimate use case, path: mcp/prompts
- title: Overview, use_cases: always, any svelte project, getting started, learning svelte, introduction, project setup, understanding framework basics, path: svelte/overview
- title: Getting started, use_cases: project setup, starting new svelte project, initial installation, choosing between sveltekit and vite, editor configuration, path: svelte/getting-started
- title: .svelte files, use_cases: always, any svelte project, component creation, project setup, learning svelte basics, path: svelte/svelte-files
- title: .svelte.js and .svelte.ts files, use_cases: shared reactive state, reusable reactive logic, state management across components, global stores, custom reactive utilities, path: svelte/svelte-js-files
- title: What are runes?, use_cases: always, any svelte 5 project, understanding core syntax, learning svelte 5, migration from svelte 4, path: svelte/what-are-runes
- title: $state, use_cases: always, any svelte project, core reactivity, state management, counters, forms, todo apps, interactive ui, data updates, class-based components, path: svelte/$state
- title: $derived, use_cases: always, any svelte project, computed values, reactive calculations, derived data, transforming state, dependent values, path: svelte/$derived
- title: $effect, use_cases: canvas drawing, third-party library integration, dom manipulation, side effects, intervals, timers, network requests, analytics tracking, path: svelte/$effect
- title: $props, use_cases: always, any svelte project, passing data to components, component communication, reusable components, component props, path: svelte/$props
- title: $bindable, use_cases: forms, user input, two-way data binding, custom input components, parent-child communication, reusable form fields, path: svelte/$bindable
- title: $inspect, use_cases: debugging, development, tracking state changes, reactive state monitoring, troubleshooting reactivity issues, path: svelte/$inspect
- title: $host, use_cases: custom elements, web components, dispatching custom events, component library, framework-agnostic components, path: svelte/$host
- title: Basic markup, use_cases: always, any svelte project, basic markup, html templating, component structure, attributes, events, props, text rendering, path: svelte/basic-markup
- title: {#if ...}, use_cases: always, conditional rendering, showing/hiding content, dynamic ui, user permissions, loading states, error handling, form validation, path: svelte/if
- title: {#each ...}, use_cases: always, lists, arrays, iteration, product listings, todos, tables, grids, dynamic content, shopping carts, user lists, comments, feeds, path: svelte/each
- title: {#key ...}, use_cases: animations, transitions, component reinitialization, forcing component remount, value-based ui updates, resetting component state, path: svelte/key
- title: {#await ...}, use_cases: async data fetching, api calls, loading states, promises, error handling, lazy loading components, dynamic imports, path: svelte/await
- title: {#snippet ...}, use_cases: reusable markup, component composition, passing content to components, table rows, list items, conditional rendering, reducing duplication, path: svelte/snippet
- title: {@render ...}, use_cases: reusable ui patterns, component composition, conditional rendering, fallback content, layout components, slot alternatives, template reuse, path: svelte/@render
- title: {@html ...}, use_cases: rendering html strings, cms content, rich text editors, markdown to html, blog posts, wysiwyg output, sanitized html injection, dynamic html content, path: svelte/@html
- title: {@attach ...}, use_cases: tooltips, popovers, dom manipulation, third-party libraries, canvas drawing, element lifecycle, interactive ui, custom directives, wrapper components, path: svelte/@attach
- title: {@const ...}, use_cases: computed values in loops, derived calculations in blocks, local variables in each iterations, complex list rendering, path: svelte/@const
- title: {@debug ...}, use_cases: debugging, development, troubleshooting, tracking state changes, monitoring variables, reactive data inspection, path: svelte/@debug
- title: bind:, use_cases: forms, user input, two-way data binding, interactive ui, media players, file uploads, checkboxes, radio buttons, select dropdowns, contenteditable, dimension tracking, path: svelte/bind
- title: use:, use_cases: custom directives, dom manipulation, third-party library integration, tooltips, click outside, gestures, focus management, element lifecycle hooks, path: svelte/use
- title: transition:, use_cases: animations, interactive ui, modals, dropdowns, notifications, conditional content, show/hide elements, smooth state changes, path: svelte/transition
- title: in: and out:, use_cases: animation, transitions, interactive ui, conditional rendering, independent enter/exit effects, modals, tooltips, notifications, path: svelte/in-and-out
- title: animate:, use_cases: sortable lists, drag and drop, reorderable items, todo lists, kanban boards, playlist editors, priority queues, animated list reordering, path: svelte/animate
- title: style:, use_cases: dynamic styling, conditional styles, theming, dark mode, responsive design, interactive ui, component styling, path: svelte/style
- title: class, use_cases: always, conditional styling, dynamic classes, tailwind css, component styling, reusable components, responsive design, path: svelte/class
- title: await, use_cases: async data fetching, loading states, server-side rendering, awaiting promises in components, async validation, concurrent data loading, path: svelte/await-expressions
- title: Scoped styles, use_cases: always, styling components, scoped css, component-specific styles, preventing style conflicts, animations, keyframes, path: svelte/scoped-styles
- title: Global styles, use_cases: global styles, third-party libraries, css resets, animations, styling body/html, overriding component styles, shared keyframes, base styles, path: svelte/global-styles
- title: Custom properties, use_cases: theming, custom styling, reusable components, design systems, dynamic colors, component libraries, ui customization, path: svelte/custom-properties
- title: Nested <style> elements, use_cases: component styling, scoped styles, dynamic styles, conditional styling, nested style tags, custom styling logic, path: svelte/nested-style-elements
- title: <svelte:boundary>, use_cases: error handling, async data loading, loading states, error recovery, flaky components, error reporting, resilient ui, path: svelte/svelte-boundary
- title: <svelte:window>, use_cases: keyboard shortcuts, scroll tracking, window resize handling, responsive layouts, online/offline detection, viewport dimensions, global event listeners, path: svelte/svelte-window
- title: <svelte:document>, use_cases: document events, visibility tracking, fullscreen detection, pointer lock, focus management, document-level interactions, path: svelte/svelte-document
- title: <svelte:body>, use_cases: mouse tracking, hover effects, cursor interactions, global body events, drag and drop, custom cursors, interactive backgrounds, body-level actions, path: svelte/svelte-body
- title: <svelte:head>, use_cases: seo optimization, page titles, meta tags, social media sharing, dynamic head content, multi-page apps, blog posts, product pages, path: svelte/svelte-head
- title: <svelte:element>, use_cases: dynamic content, cms integration, user-generated content, configurable ui, runtime element selection, flexible components, path: svelte/svelte-element
- title: <svelte:options>, use_cases: migration, custom elements, web components, legacy mode compatibility, runes mode setup, svg components, mathml components, css injection control, path: svelte/svelte-options
- title: Stores, use_cases: shared state, cross-component data, reactive values, async data streams, manual control over updates, rxjs integration, extracting logic, path: svelte/stores
- title: Context, use_cases: shared state, avoiding prop drilling, component communication, theme providers, user context, authentication state, configuration sharing, deeply nested components, path: svelte/context
- title: Lifecycle hooks, use_cases: component initialization, cleanup tasks, timers, subscriptions, dom measurements, chat windows, autoscroll features, migration from svelte 4, path: svelte/lifecycle-hooks
- title: Imperative component API, use_cases: project setup, client-side rendering, server-side rendering, ssr, hydration, testing, programmatic component creation, tooltips, dynamic mounting, path: svelte/imperative-component-api
- title: Testing, use_cases: testing, quality assurance, unit tests, integration tests, component tests, e2e tests, vitest setup, playwright setup, test automation, path: svelte/testing
- title: TypeScript, use_cases: typescript setup, type safety, component props typing, generic components, wrapper components, dom type augmentation, project configuration, path: svelte/typescript
- title: Custom elements, use_cases: web components, custom elements, component library, design system, framework-agnostic components, embedding svelte in non-svelte apps, shadow dom, path: svelte/custom-elements
- title: Svelte 4 migration guide, use_cases: upgrading svelte 3 to 4, version migration, updating dependencies, breaking changes, legacy project maintenance, path: svelte/v4-migration-guide
- title: Svelte 5 migration guide, use_cases: migrating from svelte 4 to 5, upgrading projects, learning svelte 5 syntax changes, runes migration, event handler updates, path: svelte/v5-migration-guide
- title: Frequently asked questions, use_cases: getting started, learning svelte, beginner setup, project initialization, vs code setup, formatting, testing, routing, mobile apps, troubleshooting, community support, path: svelte/faq
- title: svelte, use_cases: migration from svelte 4 to 5, upgrading legacy code, component lifecycle hooks, context api, mounting components, event dispatchers, typescript component types, path: svelte/svelte
- title: svelte/action, use_cases: typescript types, actions, use directive, dom manipulation, element lifecycle, custom behaviors, third-party library integration, path: svelte/svelte-action
- title: svelte/animate, use_cases: animated lists, sortable items, drag and drop, reordering elements, todo lists, kanban boards, playlist management, smooth position transitions, path: svelte/svelte-animate
- title: svelte/attachments, use_cases: library development, component libraries, programmatic element manipulation, migrating from actions to attachments, spreading props onto elements, path: svelte/svelte-attachments
- title: svelte/compiler, use_cases: build tools, custom compilers, ast manipulation, preprocessors, code transformation, migration scripts, syntax analysis, bundler plugins, dev tools, path: svelte/svelte-compiler
- title: svelte/easing, use_cases: animations, transitions, custom easing, smooth motion, interactive ui, modals, dropdowns, carousels, page transitions, scroll effects, path: svelte/svelte-easing
- title: svelte/events, use_cases: window events, document events, global event listeners, event delegation, programmatic event handling, cleanup functions, media queries, path: svelte/svelte-events
- title: svelte/legacy, use_cases: migration from svelte 4 to svelte 5, upgrading legacy code, event modifiers, class components, imperative component instantiation, path: svelte/svelte-legacy
- title: svelte/motion, use_cases: animation, smooth transitions, interactive ui, sliders, counters, physics-based motion, drag gestures, accessibility, reduced motion, path: svelte/svelte-motion
- title: svelte/reactivity/window, use_cases: responsive design, viewport tracking, scroll effects, window resize handling, online/offline detection, zoom level tracking, path: svelte/svelte-reactivity-window
- title: svelte/reactivity, use_cases: reactive data structures, state management with maps/sets, game boards, selection tracking, url manipulation, query params, real-time clocks, media queries, responsive design, path: svelte/svelte-reactivity
- title: svelte/server, use_cases: server-side rendering, ssr, static site generation, seo optimization, initial page load, pre-rendering, node.js server, custom server setup, path: svelte/svelte-server
- title: svelte/store, use_cases: state management, shared data, reactive stores, cross-component communication, global state, computed values, data synchronization, legacy svelte projects, path: svelte/svelte-store
- title: svelte/transition, use_cases: animations, transitions, interactive ui, modals, dropdowns, tooltips, notifications, svg animations, list animations, page transitions, path: svelte/svelte-transition
- title: Compiler errors, use_cases: animation, transitions, keyed each blocks, list animations, path: svelte/compiler-errors
- title: Compiler warnings, use_cases: accessibility, a11y compliance, wcag standards, screen readers, keyboard navigation, aria attributes, semantic html, interactive elements, path: svelte/compiler-warnings
- title: Runtime errors, use_cases: debugging errors, error handling, troubleshooting runtime issues, migration to svelte 5, component binding, effects and reactivity, path: svelte/runtime-errors
- title: Runtime warnings, use_cases: debugging state proxies, console logging reactive values, inspecting state changes, development troubleshooting, path: svelte/runtime-warnings
- title: Overview, use_cases: migrating from svelte 3/4 to svelte 5, maintaining legacy components, understanding deprecated features, gradual upgrade process, path: svelte/legacy-overview
- title: Reactive let/var declarations, use_cases: migration, legacy svelte projects, upgrading from svelte 4, understanding old reactivity, maintaining existing code, learning runes differences, path: svelte/legacy-let
- title: Reactive $: statements, use_cases: legacy mode, migration from svelte 4, reactive statements, computed values, derived state, side effects, path: svelte/legacy-reactive-assignments
- title: export let, use_cases: legacy mode, migration from svelte 4, maintaining older projects, component props without runes, exporting component methods, renaming reserved word props, path: svelte/legacy-export-let
- title: $$props and $$restProps, use_cases: legacy mode migration, component wrappers, prop forwarding, button components, reusable ui components, spreading props to child elements, path: svelte/legacy-$$props-and-$$restProps
- title: on:, use_cases: legacy mode, event handling, button clicks, forms, user interactions, component communication, event forwarding, event modifiers, path: svelte/legacy-on
- title: <slot>, use_cases: legacy mode, migrating from svelte 4, component composition, reusable components, passing content to components, modals, layouts, wrappers, path: svelte/legacy-slots
- title: $$slots, use_cases: legacy mode, conditional slot rendering, optional content sections, checking if slots provided, migrating from legacy to runes, path: svelte/legacy-$$slots
- title: <svelte:fragment>, use_cases: named slots, component composition, layout systems, avoiding wrapper divs, legacy svelte projects, slot content organization, path: svelte/legacy-svelte-fragment
- title: <svelte:component>, use_cases: dynamic components, component switching, conditional rendering, legacy mode migration, tabbed interfaces, multi-step forms, path: svelte/legacy-svelte-component
- title: <svelte:self>, use_cases: recursive components, tree structures, nested menus, file explorers, comment threads, hierarchical data, path: svelte/legacy-svelte-self
- title: Imperative component API, use_cases: migration from svelte 3/4 to 5, legacy component api, maintaining old projects, understanding deprecated patterns, path: svelte/legacy-component-api
</available-docs>
Every time you write a Svelte component or a Svelte module you MUST invoke the `svelte-autofixer` tool providing the code. The tool will return a list of issues or suggestions. If there are any issues or suggestions you MUST fix them and call the tool again with the updated code. You MUST keep doing this until the tool returns no issues or suggestions. Only then you can return the code to the user.
This is the task you will work on:
<task>
[YOUR TASK HERE]
</task>
If you are not writing the code into a file, once you have the final version of the code ask the user if it wants to generate a playground link to quickly check the code in it and if it answer yes call the `playground-link` tool and return the url to the user nicely formatted. The playground link MUST be generated only once you have the final version of the code and you are ready to share it, it MUST include an entry point file called `App.svelte` where the main component should live. If you have multiple files to include in the playground link you can include them all at the root.
```
</details>

View File

@@ -1,3 +0,0 @@
---
title: Claude Code Plugin
---

View File

@@ -1,23 +0,0 @@
---
title: Overview
---
The open source [repository](https://github.com/sveltejs/mcp) containing the code for the MCP server is also a Claude Code Marketplace plugin.
The marketplace allows you to install the `svelte` plugin which will give you the remote MCP server, [skills](skills) to instruct the LLM on how to properly write Svelte 5 code, and a specialized agent for editing Svelte files.
If possible, we recommend that you instruct the LLM to execute MCP calls with the agent (you can explicitly mention an agent in your message to delegate work to it) when creating or editing `.svelte` files or `.svelte.ts`/`.svelte.js` modules as it helps save context by handling Svelte-specific tasks more efficiently.
## Installation
To add the repository as a marketplace, launch Claude Code and type the following:
```bash
/plugin marketplace add sveltejs/mcp
```
Then, install the Svelte plugin:
```bash
/plugin install svelte
```

View File

@@ -1,11 +0,0 @@
---
title: Subagent
---
The Svelte plugin includes a specialized subagent called `svelte-file-editor` designed for creating, editing, and reviewing Svelte files.
## Benefits
The subagent has access to its own context window, allowing it to fetch the documentation, iterate with the `svelte-autofixer` tool and write to the file system without wasting context in the main agent.
The delegation should happen automatically when appropriate, but you can also explicitly request the subagent be used for Svelte-related tasks.

View File

@@ -1,3 +0,0 @@
---
title: OpenCode Plugin
---

View File

@@ -1,42 +0,0 @@
---
title: Overview
---
OpenCode has a [plugin system](https://opencode.ai/docs/plugins/) that allows developers to add MCP servers, agents and commands programmatically. Svelte has an OpenCode plugin published under `@sveltejs/opencode`.
## Installation
To install the plugin in OpenCode you can edit your [OpenCode config]() (either the global or the local one), adding `@sveltejs/opencode` to the list of plugins.
```json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@sveltejs/opencode"]
}
```
That's it! You now have the Svelte MCP server, [skills](skills), and the [file editor subagent](opencode-subagent) configured for you.
## Configuration
The default configuration for the Svelte OpenCode plugin looks like this...
```json
{
"$schema": "https://raw.githubusercontent.com/sveltejs/mcp/refs/heads/main/packages/opencode/schema.json",
"mcp": {
"type": "remote",
"enabled": true
},
"subagent": {
"enabled": true
},
"skills": {
"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`).
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`.

View File

@@ -1,11 +0,0 @@
---
title: Subagent
---
The Svelte plugin includes a specialized subagent called `svelte-file-editor` designed for creating, editing, and reviewing Svelte files.
## Benefits
The subagent has access to its own context window, allowing it to fetch the documentation, iterate with the `svelte-autofixer` tool and write to the file system without wasting context in the main agent.
The delegation should happen automatically when appropriate, but you can also explicitly request the subagent be used for Svelte-related tasks.

View File

@@ -1,76 +0,0 @@
## `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.
<a href="https://github.com/sveltejs/mcp/releases?q=svelte-code-writer" target="_blank" rel="noopener noreferrer">Open Releases page</a>
<details>
<summary>View skill content</summary>
<!-- prettier-ignore-start -->
````markdown
# Svelte 5 Code Writer
## CLI Tools
You have access to `@sveltejs/mcp` CLI for Svelte-specific assistance. Use these commands via `npx`:
### List Documentation Sections
```bash
npx @sveltejs/mcp list-sections
```
Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths.
### Get Documentation
```bash
npx @sveltejs/mcp get-documentation "<section1>,<section2>,..."
```
Retrieves full documentation for specified sections. Use after `list-sections` to fetch relevant docs.
**Example:**
```bash
npx @sveltejs/mcp get-documentation "$state,$derived,$effect"
```
### Svelte Autofixer
```bash
npx @sveltejs/mcp svelte-autofixer "<code_or_path>" [options]
```
Analyzes Svelte code and suggests fixes for common issues.
**Options:**
- `--async` - Enable async Svelte mode (default: false)
- `--svelte-version` - Target version: 4 or 5 (default: 5)
**Examples:**
```bash
# Analyze inline code (escape $ as \$)
npx @sveltejs/mcp svelte-autofixer '<script>let count = \$state(0);</script>'
# Analyze a file
npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte
# Target Svelte 4
npx @sveltejs/mcp svelte-autofixer ./Component.svelte --svelte-version 4
```
**Important:** When passing code with runes (`$state`, `$derived`, etc.) via the terminal, escape the `$` character as `\$` to prevent shell variable substitution.
## Workflow
1. **Uncertain about syntax?** Run `list-sections` then `get-documentation` for relevant topics
2. **Reviewing/debugging?** Run `svelte-autofixer` on the code to detect issues
3. **Always validate** - Run `svelte-autofixer` before finalizing any Svelte component
````
<!-- prettier-ignore-end -->
</details>

View File

@@ -1,11 +0,0 @@
---
title: Overview
---
This is the list of available skills provided by the Svelte MCP package. Skills are sets of instructions that AI agents can load on-demand to help with specific tasks.
Skills are available in both the Claude Code plugin (installed via the marketplace) and the OpenCode plugin (`@sveltejs/opencode`). They can also be manually installed in your `.claude/skills/` or `.opencode/skills/` folder.
You can download the latest skills from the [releases page](https://github.com/sveltejs/mcp/releases) or find them in the [`plugins/svelte/skills`](https://github.com/sveltejs/mcp/tree/main/plugins/svelte/skills) folder.
@include .generated/skills.md

View File

@@ -1,3 +0,0 @@
---
title: Skills
---

View File

@@ -7,20 +7,13 @@ import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
import svelteConfig from './apps/mcp-remote/svelte.config.js';
import eslint_plugin_import from 'eslint-plugin-import';
import { configs as pnpm } from 'eslint-plugin-pnpm';
const gitignore_path = fileURLToPath(new URL('./.gitignore', import.meta.url));
export default /** @type {import("eslint").Linter.Config} */ ([
includeIgnoreFile(gitignore_path),
{
ignores: [
'.claude/**/*',
'.changeset/*',
'.github/**/*.yml',
'.github/**/*.yaml',
'**/pnpm-lock.yaml',
],
ignores: ['.claude/**/*'],
},
js.configs.recommended,
...ts.configs.recommended,
@@ -55,19 +48,16 @@ export default /** @type {import("eslint").Linter.Config} */ ([
'import/no-unresolved': 'off', // this doesn't work well with typescript path mapping
'import/extensions': [
'error',
'ignorePackages',
{
ignorePackages: true,
pattern: {
js: 'always',
mjs: 'always',
cjs: 'always',
ts: 'always',
svelte: 'always',
svg: 'always',
json: 'always',
},
js: 'always',
mjs: 'always',
cjs: 'always',
ts: 'always',
svelte: 'always',
},
],
'svelte/no-navigation-without-resolve': 'off',
},
},
{
@@ -81,16 +71,4 @@ export default /** @type {import("eslint").Linter.Config} */ ([
},
},
},
{
name: 'pnpm/exclude-some-rules',
files: ['**/*.json', '**/*.yaml', '**/*.yml', 'pnpm-workspace.yaml'],
rules: {
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'func-style': 'off',
},
},
...pnpm.json,
...pnpm.yaml,
]);

View File

@@ -1,23 +0,0 @@
You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
## Available Svelte MCP Tools:
### 1. list-sections
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
### 2. get-documentation
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task.
### 3. svelte-autofixer
Analyzes Svelte code and returns issues and suggestions.
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned.
### 4. playground-link
Generates a Svelte Playground link with the provided code.
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project.

View File

@@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "The official Svelte MCP server implementation",
"type": "module",
"packageManager": "pnpm@10.28.2",
"packageManager": "pnpm@10.18.2",
"scripts": {
"build": "pnpm -r run build",
"dev": "pnpm --filter @sveltejs/mcp-remote run dev",
@@ -12,21 +12,22 @@
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"lint:fix": "prettier --write . && eslint . --fix",
"lint:inspect": "pnpm dlx @eslint/config-inspector",
"node:inspect": "pnpm dlx node-modules-inspector",
"test:unit": "vitest",
"test": "npm run test:unit -- --run",
"test:watch": "npm run test:unit -- --watch",
"inspect": "pnpm mcp-inspector",
"generate-opencode-jsonschema": "pnpm --filter @sveltejs/opencode run generate-schema",
"generate-summaries": "pnpm --filter @sveltejs/mcp-server run generate-summaries",
"generate-summaries:dry-run": "pnpm --filter @sveltejs/mcp-server run generate-summaries:dry-run",
"generate-summaries:debug": "pnpm --filter @sveltejs/mcp-server run generate-summaries:debug",
"generate-distilled": "pnpm --filter @sveltejs/mcp-server run generate-distilled",
"generate-distilled:dry-run": "pnpm --filter @sveltejs/mcp-server run generate-distilled:dry-run",
"generate-distilled:debug": "pnpm --filter @sveltejs/mcp-server run generate-distilled:debug",
"verify-distilled": "pnpm --filter @sveltejs/mcp-server run verify-distilled",
"show-verification-errors": "pnpm --filter @sveltejs/mcp-server run show-verification-errors",
"export-summaries": "pnpm --filter @sveltejs/mcp-server run export-summaries",
"generate-prompt-docs": "node --import node-resolve-ts/register scripts/update-docs-prompts.ts",
"generate-skill-docs": "node --import node-resolve-ts/register scripts/update-docs-skills.ts",
"debug:generate-summaries": "pnpm --filter @sveltejs/mcp-server run debug:generate-summaries",
"release": "pnpm --filter @sveltejs/mcp run build && changeset publish",
"changeset:version": "changeset version && pnpm --filter @sveltejs/mcp run update:version && git add --all",
"sync-opencode-skills": "rm -rf packages/opencode/skills && cp -r plugins/svelte/skills packages/opencode/skills",
"sync-agents-md": "rm -f packages/opencode/instructions/opencode-agents.md && rm -f documentation/docs/10-introduction/.generated/agents.md && mkdir -p packages/opencode/instructions && mkdir -p documentation/docs/10-introduction/.generated && cp instructions/AGENTS.md packages/opencode/instructions/opencode-agents.md && cp instructions/AGENTS.md documentation/docs/10-introduction/.generated/agents.md"
"changeset:version": "changeset version && pnpm --filter @sveltejs/mcp run update:version && git add --all"
},
"keywords": [
"svelte",
@@ -36,24 +37,28 @@
],
"private": true,
"devDependencies": {
"@changesets/cli": "catalog:tooling",
"@eslint/compat": "catalog:lint",
"@eslint/js": "catalog:lint",
"@modelcontextprotocol/inspector": "catalog:ai",
"@sveltejs/adapter-vercel": "catalog:svelte",
"@svitejs/changesets-changelog-github-compact": "catalog:tooling",
"eslint": "catalog:lint",
"eslint-config-prettier": "catalog:lint",
"eslint-plugin-import": "catalog:lint",
"eslint-plugin-pnpm": "catalog:lint",
"eslint-plugin-svelte": "catalog:lint",
"globals": "catalog:lint",
"node-resolve-ts": "catalog:tooling",
"prettier": "catalog:lint",
"prettier-plugin-svelte": "catalog:lint",
"publint": "catalog:tooling",
"typescript": "catalog:tooling",
"typescript-eslint": "catalog:lint",
"vitest": "catalog:tooling"
"@changesets/cli": "^2.29.7",
"@eslint/compat": "^1.3.2",
"@eslint/js": "^9.36.0",
"@modelcontextprotocol/inspector": "^0.17.0",
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
"eslint": "^9.36.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-svelte": "^3.12.3",
"globals": "^16.0.0",
"node-resolve-ts": "^1.0.2",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"publint": "^0.3.13",
"typescript": "^5.0.0",
"typescript-eslint": "^8.44.1",
"vite-node": "^3.2.4",
"vitest": "^3.2.3"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
}
}

View File

@@ -14,6 +14,6 @@
"license": "ISC",
"type": "module",
"dependencies": {
"drizzle-orm": "catalog:orm"
"drizzle-orm": "^0.44.0"
}
}

View File

@@ -10,39 +10,46 @@
"type": "module",
"scripts": {
"test": "vitest",
"generate-summaries": "node scripts/generate-summaries.ts --experimental-strip-types",
"debug:generate-summaries": "DEBUG_MODE=1 node scripts/generate-summaries.ts --experimental-strip-types"
"generate-summaries": "node --import node-resolve-ts/register scripts/generate-summaries.ts && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"generate-summaries:dry-run": "node --import node-resolve-ts/register scripts/generate-summaries.ts --dry-run && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"generate-summaries:debug": "DEBUG_MODE=1 node --import node-resolve-ts/register scripts/generate-summaries.ts && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"generate-distilled": "node --import node-resolve-ts/register scripts/generate-summaries.ts --prompt-type distilled && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"generate-distilled:dry-run": "node --import node-resolve-ts/register scripts/generate-summaries.ts --prompt-type distilled --dry-run && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"generate-distilled:debug": "DEBUG_MODE=1 node --import node-resolve-ts/register scripts/generate-summaries.ts --prompt-type distilled && prettier --write --log-level silent 'src/**/*.{js,ts,json}'",
"verify-distilled": "node --import node-resolve-ts/register scripts/verify-distilled.ts",
"show-verification-errors": "node --import node-resolve-ts/register scripts/show-verification-errors.ts",
"export-summaries": "node --import node-resolve-ts/register scripts/export-summaries.ts && prettier --write --log-level silent 'src/**/*.{js,ts,json}'"
},
"exports": {
".": "./src/index.ts",
"./handlers": "./src/mcp/handlers/tools/handlers.ts"
"./distilled.json": "./src/distilled.json",
"./use-cases.json": "./src/use_cases.json"
},
"peerDependencies": {
"drizzle-orm": "^0.45.0"
"drizzle-orm": "^0.44.0"
},
"dependencies": {
"@mcp-ui/server": "catalog:ai",
"@sveltejs/mcp-schema": "workspace:^",
"@tmcp/adapter-valibot": "catalog:tmcp",
"@tmcp/transport-in-memory": "catalog:tmcp",
"@typescript-eslint/parser": "catalog:lint",
"eslint": "catalog:lint",
"eslint-plugin-svelte": "catalog:lint",
"svelte": "catalog:svelte",
"svelte-eslint-parser": "catalog:lint",
"tmcp": "catalog:tmcp",
"ts-blank-space": "catalog:tooling",
"typescript-eslint": "catalog:lint",
"valibot": "catalog:tooling",
"vitest": "catalog:tooling",
"zimmerframe": "catalog:tooling"
"@tmcp/adapter-valibot": "^0.1.4",
"@typescript-eslint/parser": "^8.44.0",
"eslint": "^9.36.0",
"eslint-plugin-svelte": "^3.12.3",
"svelte": "^5.39.2",
"svelte-eslint-parser": "^1.3.2",
"tmcp": "^1.13.0",
"ts-blank-space": "^0.6.2",
"typescript-eslint": "^8.44.0",
"valibot": "^1.1.0",
"vitest": "^3.2.4",
"zimmerframe": "^1.1.4"
},
"devDependencies": {
"@anthropic-ai/sdk": "catalog:ai",
"@sveltejs/kit": "catalog:svelte",
"@types/eslint-scope": "catalog:lint",
"@types/estree": "catalog:tooling",
"@typescript-eslint/types": "catalog:lint",
"dotenv": "catalog:tooling"
"@anthropic-ai/sdk": "^0.65.0",
"@sveltejs/kit": "^2.42.2",
"@types/eslint-scope": "^8.3.2",
"@types/estree": "^1.0.8",
"@typescript-eslint/types": "^8.44.0",
"commander": "^13.1.0",
"dotenv": "^17.2.3"
}
}

View File

@@ -0,0 +1,108 @@
#!/usr/bin/env node
import 'dotenv/config';
import { readFile, access } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { Command } from 'commander';
import * as v from 'valibot';
import { summary_data_schema, type SummaryData } from '../src/lib/schemas.ts';
import { export_summaries_to_markdown } from './lib/export-markdown.ts';
interface CliOptions {
type: 'use_cases' | 'distilled' | 'both';
}
const current_filename = fileURLToPath(import.meta.url);
const current_dirname = path.dirname(current_filename);
const program = new Command();
program
.name('export-summaries')
.description('Export summaries from JSON files to individual markdown files')
.version('1.0.0')
.option('-t, --type <type>', 'Type to export: "use_cases", "distilled", or "both"', 'both');
async function read_file_as_string(
file_path: string,
encoding: BufferEncoding = 'utf-8',
): Promise<string> {
const content = await readFile(file_path, encoding);
return v.parse(v.string(), content);
}
async function load_summaries_json(output_path: string): Promise<SummaryData | null> {
try {
await access(output_path);
} catch {
return null;
}
const content = await read_file_as_string(output_path, 'utf-8');
const data = JSON.parse(content);
const validated = v.safeParse(summary_data_schema, data);
if (!validated.success) {
throw new Error(
`File has invalid schema: ${output_path}\n` +
`Validation errors: ${JSON.stringify(validated.issues, null, 2)}`,
);
}
return validated.output;
}
async function export_summaries_for_type(type: 'use_cases' | 'distilled'): Promise<void> {
const json_filename = type === 'distilled' ? 'distilled.json' : 'use_cases.json';
const input_path = path.join(current_dirname, `../src/${json_filename}`);
console.log(`\n📁 Processing ${type.toUpperCase()}...`);
console.log(` Input: ${json_filename}`);
// Load the JSON file
console.log(` 📂 Loading ${json_filename}...`);
const data = await load_summaries_json(input_path);
if (!data) {
console.error(` ❌ Error: Could not load ${json_filename}`);
return;
}
const summaries = data.summaries;
console.log(` ✅ Found ${Object.keys(summaries).length} summaries`);
// Use shared export function
await export_summaries_to_markdown(summaries, type, path.join(current_dirname, '../summaries'));
}
async function main() {
program.parse();
const options = program.opts<CliOptions>();
console.log('🚀 Starting summary export...');
// Validate type option
if (!['use_cases', 'distilled', 'both'].includes(options.type)) {
console.error('❌ Error: --type must be "use_cases", "distilled", or "both"');
process.exit(1);
}
// Export based on type option
if (options.type === 'both') {
await export_summaries_for_type('use_cases');
await export_summaries_for_type('distilled');
} else {
await export_summaries_for_type(options.type);
}
console.log('\n✅ Export complete!');
console.log(
'\n📊 Summary files have been written to:',
path.join(current_dirname, '../summaries/'),
);
}
main().catch((error) => {
console.error('❌ Fatal error:', error);
process.exit(1);
});

View File

@@ -1,58 +1,59 @@
#!/usr/bin/env node
import 'dotenv/config';
import { writeFile, mkdir } from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import { writeFile, mkdir, readFile, access } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { Command } from 'commander';
import { get_sections } from '../src/mcp/utils.ts';
import { AnthropicProvider } from '../src/lib/anthropic.ts';
import { type AnthropicBatchRequest, type SummaryData } from '../src/lib/schemas.ts';
import {
type AnthropicBatchRequest,
type SummaryData,
summary_data_schema,
} from '../src/lib/schemas.ts';
import * as v from 'valibot';
import { DISTILLED_PROMPT, USE_CASES_PROMPT } from '../src/mcp/handlers/tools/prompts.ts';
import { export_summaries_to_markdown } from './lib/export-markdown.ts';
interface CliOptions {
force: boolean;
dryRun: boolean;
debug: boolean;
promptType: 'use-cases' | 'distilled';
}
interface SectionChange {
slug: string;
title: string;
url: string;
change_type: 'new' | 'changed' | 'removed';
}
const current_filename = fileURLToPath(import.meta.url);
const current_dirname = path.dirname(current_filename);
const USE_CASES_PROMPT = `
You are tasked with analyzing Svelte 5 and SvelteKit documentation pages to identify when they would be useful.
async function read_file_as_string(
file_path: string,
encoding: BufferEncoding = 'utf-8',
): Promise<string> {
const content = await readFile(file_path, encoding);
return v.parse(v.string(), content);
}
Your task:
1. Read the documentation page content provided
2. Identify the main use cases, scenarios, or queries where this documentation would be relevant
3. Create a VERY SHORT, comma-separated list of use cases (maximum 200 characters total)
4. Think about what a developer might be trying to build or accomplish when they need this documentation
const program = new Command();
Guidelines:
- Focus on WHEN this documentation would be needed, not WHAT it contains
- Consider specific project types (e.g., "e-commerce site", "blog", "dashboard", "social media app")
- Consider specific features (e.g., "authentication", "forms", "data fetching", "animations")
- Consider specific components (e.g., "slider", "modal", "dropdown", "card")
- Consider development stages (e.g., "project setup", "deployment", "testing", "migration")
- Use "always" for fundamental concepts that apply to virtually all Svelte projects
- Be concise but specific
- Use lowercase
- Separate multiple use cases with commas
Examples of good use_cases:
- "always, any svelte project, core reactivity"
- "authentication, login systems, user management"
- "e-commerce, product listings, shopping carts"
- "forms, user input, data submission"
- "deployment, production builds, hosting setup"
- "animation, transitions, interactive ui"
- "routing, navigation, multi-page apps"
- "blog, content sites, markdown rendering"
Requirements:
- Maximum 200 characters (including spaces and commas)
- Lowercase only
- Comma-separated list of use cases
- Focus on WHEN/WHY someone would need this, not what it is
- Be specific about project types, features, or components when applicable
- Use "always" sparingly, only for truly universal concepts
- Do not include quotes or special formatting in your response
- Respond with ONLY the use cases text, no additional text
Here is the documentation page content to analyze:
`;
program
.name('generate-summaries')
.description('Generate use case summaries for Svelte documentation sections')
.version('1.0.0')
.option('-f, --force', 'Force regeneration of all summaries', false)
.option('-d, --dry-run', 'Show what would be changed without making API calls', false)
.option('--debug', 'Debug mode: process only 2 sections', false)
.option(
'-p, --prompt-type <type>',
'Prompt type to use: "use-cases" or "distilled"',
'use-cases',
);
async function fetch_section_content(url: string) {
const response = await fetch(url, { signal: AbortSignal.timeout(30000) });
@@ -62,180 +63,382 @@ async function fetch_section_content(url: string) {
return await response.text();
}
export async function load_existing_summaries(output_path: string): Promise<SummaryData | null> {
try {
await access(output_path);
} catch {
return null;
}
const content = await read_file_as_string(output_path, 'utf-8');
const data = JSON.parse(content);
const validated = v.safeParse(summary_data_schema, data);
if (!validated.success) {
throw new Error(
`Existing file has invalid schema. Please fix or delete the file at: ${output_path}\n` +
`Validation errors: ${JSON.stringify(validated.issues, null, 2)}`,
);
}
return validated.output;
}
function detect_changes(
current_sections: Array<{ slug: string; title: string; url: string }>,
existing_data: SummaryData | null,
current_content: Map<string, string>,
force: boolean,
): {
to_process: Array<{ slug: string; title: string; url: string }>;
to_remove: string[];
changes: SectionChange[];
} {
if (!existing_data || force) {
// First run or force regeneration
return {
to_process: current_sections,
to_remove: [],
changes: current_sections.map((s) => ({
...s,
change_type: force ? 'changed' : 'new',
})),
};
}
const existing_summaries = existing_data.summaries;
const existing_content = existing_data.content;
const existing_slugs = new Set(Object.keys(existing_summaries));
const current_slugs = new Set(current_sections.map((s) => s.slug));
const sections_to_process: typeof current_sections = [];
const changes: SectionChange[] = [];
// Check for new and changed sections
for (const section of current_sections) {
const content = current_content.get(section.slug);
if (!content) {
throw new Error(`No content found for section: ${section.slug}`);
}
if (!existing_slugs.has(section.slug)) {
// New section
sections_to_process.push(section);
changes.push({ ...section, change_type: 'new' });
} else {
// Existing section - check if content changed
const stored_content = existing_content[section.slug] ?? '';
if (content !== stored_content) {
// Content has changed
sections_to_process.push(section);
changes.push({ ...section, change_type: 'changed' });
}
}
}
// Find removed sections
const removed_slugs: string[] = [];
for (const slug of existing_slugs) {
if (!current_slugs.has(slug)) {
removed_slugs.push(slug);
changes.push({
slug,
title: '<removed>',
url: '',
change_type: 'removed',
});
}
}
return {
to_process: sections_to_process,
to_remove: removed_slugs,
changes,
};
}
async function main() {
program.parse();
const options = program.opts<CliOptions>();
// Allow DEBUG_MODE env var as well
const debug = options.debug || process.env.DEBUG_MODE === '1';
console.log('🚀 Starting use cases generation...');
// Check for API key
const api_key = process.env.ANTHROPIC_API_KEY;
if (!api_key) {
console.error('❌ Error: ANTHROPIC_API_KEY environment variable is required');
console.error('Please set it in packages/mcp-server/.env file or export it:');
console.error('export ANTHROPIC_API_KEY=your_api_key_here');
process.exit(1);
// Determine output file based on prompt type
const output_filename = options.promptType === 'distilled' ? 'distilled.json' : 'use_cases.json';
const output_path = path.join(current_dirname, `../src/${output_filename}`);
// Select prompt based on prompt type
const selected_prompt = options.promptType === 'distilled' ? DISTILLED_PROMPT : USE_CASES_PROMPT;
// Display mode information
console.log(`📝 PROMPT MODE: ${options.promptType.toUpperCase()}${output_filename}\n`);
if (options.dryRun) {
console.log('🔍 DRY RUN MODE - No API calls will be made\n');
}
if (options.force) {
console.log('⚡ FORCE MODE - Regenerating all summaries\n');
}
if (debug) {
console.log('🐛 DEBUG MODE - Will process only 2 sections\n');
}
// Load existing summaries
console.log('📂 Loading existing summaries...');
const existing_data = await load_existing_summaries(output_path);
if (existing_data) {
console.log(
`✅ Found existing summaries with ${Object.keys(existing_data.summaries).length} entries`,
);
} else {
console.log('📝 No existing summaries found - will process all sections');
}
// Get all sections
console.log('📚 Fetching documentation sections...');
let sections = await get_sections();
console.log(`Found ${sections.length} sections`);
const all_sections = await get_sections();
console.log(`Found ${all_sections.length} sections from API`);
// Debug mode: limit to 2 sections
const debug_mode = process.env.DEBUG_MODE === '1';
if (debug_mode) {
console.log('🐛 DEBUG_MODE enabled - processing only 2 sections');
sections = sections.slice(0, 2);
// Download content for ALL sections (needed to compute hashes)
console.log('\n📥 Downloading section content...');
const section_content = new Map<string, string>();
for (let i = 0; i < all_sections.length; i++) {
const section = all_sections[i]!;
console.log(` Fetching ${i + 1}/${all_sections.length}: ${section.title}`);
const content = await fetch_section_content(section.url);
section_content.set(section.slug, content);
}
// Fetch content for each section
console.log('📥 Downloading section content...');
console.log(`✅ Successfully downloaded ${section_content.size} sections`);
// Detect what needs to be processed
console.log('\n🔍 Checking for content changes...');
const { to_process, to_remove, changes } = detect_changes(
all_sections,
existing_data,
section_content,
options.force,
);
// Display changes
console.log('\n📊 Change Summary:');
const new_count = changes.filter((c) => c.change_type === 'new').length;
const changed_count = changes.filter((c) => c.change_type === 'changed').length;
const removed_count = changes.filter((c) => c.change_type === 'removed').length;
console.log(` ✨ New sections: ${new_count}`);
console.log(` 🔄 Changed sections: ${changed_count}`);
console.log(` ❌ Removed sections: ${removed_count}`);
console.log(` 📝 To process: ${to_process.length}`);
if (changes.length > 0) {
console.log('\n📋 Detailed changes:');
for (const change of changes) {
const emoji =
change.change_type === 'new' ? ' ✨' : change.change_type === 'changed' ? ' 🔄' : ' ❌';
console.log(`${emoji} [${change.change_type.toUpperCase()}] ${change.slug}`);
}
}
// Exit early if nothing to do
if (to_process.length === 0 && to_remove.length === 0) {
console.log('\n✅ No changes detected - everything is up to date!');
return;
}
// Debug mode: limit sections
let sections_to_process = to_process;
if (debug) {
console.log('\n🐛 Processing only 2 sections for debugging');
sections_to_process = to_process.slice(0, 2);
}
// Dry run mode: exit before API calls
if (options.dryRun) {
console.log('\n🔍 DRY RUN complete - no changes were made');
console.log(`Would have processed ${sections_to_process.length} sections`);
console.log(`Would have removed ${to_remove.length} sections`);
return;
}
// Process with Anthropic API if we have sections to process
const new_summaries: Record<string, string> = {};
const sections_with_content: Array<{
section: (typeof sections)[number];
section: (typeof sections_to_process)[number];
content: string;
index: number;
}> = [];
const download_errors: Array<{ section: string; error: string }> = [];
for (let i = 0; i < sections.length; i++) {
const section = sections[i]!;
try {
console.log(`Fetching ${i + 1}/${sections.length}: ${section.title}`);
const content = await fetch_section_content(section.url);
if (sections_to_process.length === 0) {
console.log('\n📦 Only removing old sections, no API calls needed');
} else {
// Check for API key
const api_key = process.env.ANTHROPIC_API_KEY;
if (!api_key) {
console.error('❌ Error: ANTHROPIC_API_KEY environment variable is required');
console.error('Please set it in packages/mcp-server/.env file or export it:');
console.error('export ANTHROPIC_API_KEY=your_api_key_here');
process.exit(1);
}
// Build sections_with_content from already-downloaded content
console.log('\n📦 Preparing sections for processing...');
for (let i = 0; i < sections_to_process.length; i++) {
const section = sections_to_process[i]!;
const content = section_content.get(section.slug);
if (!content) {
throw new Error(`No content available for ${section.title}`);
}
sections_with_content.push({
section,
content,
index: i,
});
} catch (error) {
const error_msg = error instanceof Error ? error.message : String(error);
console.error(`⚠️ Failed to fetch ${section.title}:`, error_msg);
download_errors.push({ section: section.title, error: error_msg });
}
}
console.log(`✅ Successfully downloaded ${sections_with_content.length} sections`);
if (sections_with_content.length === 0) {
console.error('❌ No sections were successfully downloaded');
process.exit(1);
}
// Initialize Anthropic client
console.log('🤖 Initializing Anthropic API...');
const anthropic = new AnthropicProvider('claude-sonnet-4-5-20250929', api_key);
// Prepare batch requests
console.log('📦 Preparing batch requests...');
const batch_requests: AnthropicBatchRequest[] = sections_with_content.map(
({ content, index }) => ({
custom_id: `section-${index}`,
params: {
model: anthropic.get_model_identifier(),
max_tokens: 250,
messages: [
{
role: 'user',
content: USE_CASES_PROMPT + content,
},
],
temperature: 0,
},
}),
);
// Create and process batch
console.log('🚀 Creating batch job...');
const batch_response = await anthropic.create_batch(batch_requests);
console.log(`✅ Batch created with ID: ${batch_response.id}`);
// Poll for completion
console.log('⏳ Waiting for batch to complete...');
let batch_status = await anthropic.get_batch_status(batch_response.id);
while (batch_status.processing_status === 'in_progress') {
const { succeeded, processing, errored } = batch_status.request_counts;
console.log(` Progress: ${succeeded} succeeded, ${processing} processing, ${errored} errored`);
await new Promise((resolve) => setTimeout(resolve, 5000));
batch_status = await anthropic.get_batch_status(batch_response.id);
}
console.log('✅ Batch processing completed!');
// Get results
if (!batch_status.results_url) {
throw new Error('Batch completed but no results URL available');
}
console.log('📥 Downloading results...');
const results = await anthropic.get_batch_results(batch_status.results_url);
// Process results
console.log('📊 Processing results...');
const summaries: Record<string, string> = {};
const errors: Array<{ section: string; error: string }> = [];
for (const result of results) {
const index = parseInt(result.custom_id.split('-')[1] ?? '0');
const section_data = sections_with_content.find((s) => s.index === index);
if (!section_data) {
console.warn(`⚠️ Could not find section for index ${index}`);
continue;
}
const { section } = section_data;
console.log(`✅ Prepared ${sections_with_content.length} sections for processing`);
if (result.result.type !== 'succeeded' || !result.result.message) {
const error_msg = result.result.error?.message || 'Failed or no message';
console.error(`${section.title}: ${error_msg}`);
errors.push({ section: section.title, error: error_msg });
continue;
console.log('\n🤖 Initializing Anthropic API...');
const anthropic = new AnthropicProvider('claude-sonnet-4-5-20250929', api_key);
// Prepare batch requests
console.log('📦 Preparing batch requests...');
const batch_requests: AnthropicBatchRequest[] = sections_with_content.map(
({ content, index }) => ({
custom_id: `section-${index}`,
params: {
model: anthropic.get_model_identifier(),
max_tokens: 8192,
messages: [
{
role: 'user',
content:
`<instructions>${selected_prompt}</instructions>` +
`<documentation>${content}</documentation>`,
},
],
temperature: 0,
},
}),
);
// Create and process batch
console.log('🚀 Creating batch job...');
const batch_response = await anthropic.create_batch(batch_requests);
console.log(`✅ Batch created with ID: ${batch_response.id}`);
// Poll for completion
console.log('⏳ Waiting for batch to complete...');
let batch_status = await anthropic.get_batch_status(batch_response.id);
while (batch_status.processing_status === 'in_progress') {
const { succeeded, processing, errored } = batch_status.request_counts;
console.log(
` Progress: ${succeeded} succeeded, ${processing} processing, ${errored} errored`,
);
await new Promise((resolve) => setTimeout(resolve, 5000));
batch_status = await anthropic.get_batch_status(batch_response.id);
}
const output_content = result.result.message.content[0]?.text;
if (output_content) {
summaries[section.slug] = output_content.trim();
console.log('✅ Batch processing completed!');
// Get results
if (!batch_status.results_url) {
throw new Error('Batch completed but no results URL available');
}
console.log('📥 Downloading results...');
const results = await anthropic.get_batch_results(batch_status.results_url);
// Process results
console.log('📊 Processing results...');
for (const result of results) {
const index = parseInt(result.custom_id.split('-')[1] ?? '0');
const section_data = sections_with_content.find((s) => s.index === index);
if (!section_data) {
throw new Error(`Could not find section for index ${index}`);
}
const { section } = section_data;
if (result.result.type !== 'succeeded' || !result.result.message) {
const error_msg = result.result.error?.message || 'Failed or no message';
throw new Error(`Failed to generate summary for ${section.title}: ${error_msg}`);
}
const output_content = result.result.message.content[0]?.text;
if (!output_content) {
throw new Error(`No text content in result for ${section.title}`);
}
new_summaries[section.slug] = output_content.trim();
console.log(`${section.title}`);
}
// Merge with existing summaries
console.log('\n📦 Merging results...');
}
// Write output to JSON file
console.log('💾 Writing results to file...');
const output_path = path.join(current_dirname, '../src/use_cases.json');
const output_dir = path.dirname(output_path);
// Start with existing summaries or empty object
const merged_summaries: Record<string, string> = existing_data
? { ...existing_data.summaries }
: {};
// Add/update new summaries
Object.assign(merged_summaries, new_summaries);
// Remove deleted sections from summaries
for (const slug of to_remove) {
delete merged_summaries[slug];
console.log(` 🗑️ Removed: ${slug}`);
}
// Write output
console.log('\n💾 Writing results to file...');
const output_dir = path.dirname(output_path);
await mkdir(output_dir, { recursive: true });
const summary_data: SummaryData = {
generated_at: new Date().toISOString(),
model: anthropic.get_model_identifier(),
total_sections: sections.length,
successful_summaries: Object.keys(summaries).length,
failed_summaries: errors.length,
summaries,
errors: errors.length > 0 ? errors : undefined,
download_errors: download_errors.length > 0 ? download_errors : undefined,
model: 'claude-sonnet-4-5-20250929',
total_sections: all_sections.length,
successful_summaries: Object.keys(merged_summaries).length,
summaries: merged_summaries,
content: Object.fromEntries(section_content),
};
await writeFile(output_path, JSON.stringify(summary_data, null, 2), 'utf-8');
// Export summaries to markdown files
console.log('\n📁 Exporting summaries to markdown files...');
const markdown_type = options.promptType === 'distilled' ? 'distilled' : 'use_cases';
const markdown_files_created = await export_summaries_to_markdown(
merged_summaries,
markdown_type,
path.join(current_dirname, '../summaries'),
);
// Print summary
console.log('\n📊 Summary:');
console.log(` Total sections: ${sections.length}`);
console.log(` Successfully downloaded: ${sections_with_content.length}`);
console.log(` Download failures: ${download_errors.length}`);
console.log(` Successfully analyzed: ${Object.keys(summaries).length}`);
console.log(` Analysis failures: ${errors.length}`);
console.log('\n📊 Final Summary:');
console.log(` Total sections in API: ${all_sections.length}`);
console.log(` Sections processed: ${sections_with_content.length}`);
console.log(` New summaries generated: ${Object.keys(new_summaries).length}`);
console.log(` Sections removed: ${to_remove.length}`);
console.log(` Total summaries in file: ${Object.keys(merged_summaries).length}`);
console.log(` Markdown files created: ${markdown_files_created}`);
console.log(`\n✅ Results written to: ${output_path}`);
if (download_errors.length > 0) {
console.log('\n⚠ Some sections failed to download:');
download_errors.forEach((e) => console.log(` - ${e.section}: ${e.error}`));
}
if (errors.length > 0) {
console.log('\n⚠ Some sections failed to analyze:');
errors.forEach((e) => console.log(` - ${e.section}: ${e.error}`));
}
console.log(
`✅ Markdown files written to: ${path.join(current_dirname, `../summaries/${markdown_type}/`)}`,
);
}
main().catch((error) => {

View File

@@ -0,0 +1,54 @@
import { writeFile, mkdir, rm } from 'node:fs/promises';
import path from 'node:path';
/**
* Export summaries to markdown files in nested directory structure
* @param summaries - Record of slug -> content mappings
* @param type - Type of summaries ('use_cases' or 'distilled')
* @param base_dir - Base directory for summaries (e.g., 'packages/mcp-server/summaries')
* @returns Number of files created
*/
export async function export_summaries_to_markdown(
summaries: Record<string, string>,
type: 'use_cases' | 'distilled',
base_dir: string,
): Promise<number> {
const output_base_dir = path.join(base_dir, type);
const summary_count = Object.keys(summaries).length;
console.log(` 📁 Target: summaries/${type}/`);
console.log(` 📊 Total summaries: ${summary_count}`);
// Clean existing directory for this type
console.log(` 🧹 Cleaning ${type} directory...`);
try {
await rm(output_base_dir, { recursive: true, force: true });
} catch {
// Directory might not exist, that's okay
}
// Create base output directory
await mkdir(output_base_dir, { recursive: true });
let created_count = 0;
// Write each summary to a markdown file
for (const [slug, content] of Object.entries(summaries)) {
const file_path = path.join(output_base_dir, `${slug}.md`);
const file_dir = path.dirname(file_path);
// Create nested directories if needed
await mkdir(file_dir, { recursive: true });
// Write the markdown file
await writeFile(file_path, content, 'utf-8');
created_count++;
if (created_count % 10 === 0) {
console.log(` 📝 Created ${created_count}/${summary_count} files...`);
}
}
console.log(` ✅ Successfully created ${created_count} markdown files`);
return created_count;
}

View File

@@ -0,0 +1,91 @@
#!/usr/bin/env node
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as v from 'valibot';
const current_filename = fileURLToPath(import.meta.url);
const current_dirname = path.dirname(current_filename);
const verification_output_schema = v.object({
generated_at: v.string(),
model: v.string(),
total_sections: v.number(),
verified_sections: v.number(),
accurate_count: v.number(),
not_accurate_count: v.number(),
results: v.array(
v.object({
slug: v.string(),
status: v.union([v.literal('ACCURATE'), v.literal('NOT_ACCURATE')]),
reasoning: v.string(),
}),
),
});
async function main() {
const verification_path = path.join(current_dirname, '../src/distilled-verification.json');
console.log('📂 Reading verification results...\n');
let content: string;
try {
content = await readFile(verification_path, 'utf-8');
} catch {
console.error('❌ Error: Could not find distilled-verification.json');
console.error('Please run `pnpm verify-distilled` first to generate the file.');
process.exit(1);
}
const data = JSON.parse(content);
const validated = v.safeParse(verification_output_schema, data);
if (!validated.success) {
console.error('❌ Error: Invalid verification file format');
console.error(JSON.stringify(validated.issues, null, 2));
process.exit(1);
}
const verification_data = validated.output;
// Filter for NOT_ACCURATE results
const not_accurate = verification_data.results.filter((r) => r.status === 'NOT_ACCURATE');
// Print header
console.log('📊 Verification Results Summary');
console.log('═'.repeat(80));
console.log(`Generated: ${new Date(verification_data.generated_at).toLocaleString()}`);
console.log(`Model: ${verification_data.model}`);
console.log(`Total Sections: ${verification_data.total_sections}`);
console.log(`Verified: ${verification_data.verified_sections}`);
console.log(
`✅ Accurate: ${verification_data.accurate_count} (${((verification_data.accurate_count / verification_data.verified_sections) * 100).toFixed(1)}%)`,
);
console.log(
`❌ Not Accurate: ${verification_data.not_accurate_count} (${((verification_data.not_accurate_count / verification_data.verified_sections) * 100).toFixed(1)}%)`,
);
console.log('═'.repeat(80));
if (not_accurate.length === 0) {
console.log('\n🎉 All sections are accurate! No issues found.');
return;
}
// Print all NOT_ACCURATE entries
console.log(`\n❌ NOT ACCURATE SECTIONS (${not_accurate.length}):\n`);
for (let i = 0; i < not_accurate.length; i++) {
const result = not_accurate[i]!;
console.log(`${i + 1}. ${result.slug}`);
console.log(` Reasoning: ${result.reasoning}`);
console.log('');
}
console.log('═'.repeat(80));
console.log(`\nFound ${not_accurate.length} section(s) that need review or regeneration.`);
}
main().catch((error) => {
console.error('❌ Fatal error:', error);
process.exit(1);
});

View File

@@ -0,0 +1,292 @@
#!/usr/bin/env node
import 'dotenv/config';
import { writeFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { AnthropicProvider } from '../src/lib/anthropic.ts';
import type { AnthropicBatchRequest } from '../src/lib/schemas.ts';
import distilled_data from '../src/distilled.json' with { type: 'json' };
import * as v from 'valibot';
interface VerificationResult {
slug: string;
status: 'ACCURATE' | 'NOT_ACCURATE';
reasoning: string;
}
interface VerificationOutput {
generated_at: string;
model: string;
total_sections: number;
verified_sections: number;
accurate_count: number;
not_accurate_count: number;
results: VerificationResult[];
}
const current_filename = fileURLToPath(import.meta.url);
const current_dirname = path.dirname(current_filename);
const verification_output_schema = v.object({
generated_at: v.string(),
model: v.string(),
total_sections: v.number(),
verified_sections: v.number(),
accurate_count: v.number(),
not_accurate_count: v.number(),
results: v.array(
v.object({
slug: v.string(),
status: v.union([v.literal('ACCURATE'), v.literal('NOT_ACCURATE')]),
reasoning: v.string(),
}),
),
});
const VERIFICATION_PROMPT = `You are tasked with verifying the accuracy of a distilled/condensed version of documentation against the original content.
Your task:
1. Read both the ORIGINAL documentation and the DISTILLED version provided below
2. Determine if the distilled version accurately represents the key information from the original
3. Check for any factual errors, misleading statements, or critical omissions
4. Return your verdict as either "ACCURATE" or "NOT_ACCURATE"
Guidelines for determining accuracy:
- ACCURATE: The distilled version correctly captures the essential information, even if shortened
- ACCURATE: Minor formatting changes or reasonable simplifications are acceptable
- ACCURATE: Examples may be condensed as long as the core concept is preserved
- NOT_ACCURATE: Any factual errors or contradictions with the original
- NOT_ACCURATE: Missing critical information that would mislead developers
- NOT_ACCURATE: Incorrect code examples or API usage
You must respond in exactly this format:
STATUS: [ACCURATE or NOT_ACCURATE]
REASONING: [Brief explanation of your decision in one sentence]
Do not include any other text, formatting, or markdown in your response.`;
function parse_verification_response(text: string): {
status: 'ACCURATE' | 'NOT_ACCURATE';
reasoning: string;
} | null {
// Try to extract STATUS and REASONING using regex
const status_match = text.match(/STATUS:\s*(ACCURATE|NOT_ACCURATE)/i);
const reasoning_match = text.match(/REASONING:\s*(.+?)(?:\n|$)/i);
if (status_match && reasoning_match) {
return {
status: status_match[1]!.toUpperCase() as 'ACCURATE' | 'NOT_ACCURATE',
reasoning: reasoning_match[1]!.trim(),
};
}
// Fallback: try to find just "ACCURATE" or "NOT_ACCURATE" anywhere in the response
const accurate_match = text.match(/\b(NOT_ACCURATE|ACCURATE)\b/i);
if (accurate_match) {
// Extract some context as reasoning
const lines = text.split('\n').filter((line) => line.trim());
const reasoning = lines.slice(0, 3).join(' ').slice(0, 200);
return {
status: accurate_match[1]!.toUpperCase() as 'ACCURATE' | 'NOT_ACCURATE',
reasoning: reasoning || 'Could not extract detailed reasoning',
};
}
return null;
}
async function main() {
console.log('🔍 Starting distilled verification...\n');
const output_path = path.join(current_dirname, '../src/distilled-verification.json');
// Load distilled data
console.log('📂 Loading distilled.json...');
const { summaries, content } = distilled_data;
const sections = Object.keys(summaries);
console.log(`Found ${sections.length} sections to verify\n`);
// Check for API key
const api_key = process.env.ANTHROPIC_API_KEY;
if (!api_key) {
console.error('❌ Error: ANTHROPIC_API_KEY environment variable is required');
console.error('Please set it in packages/mcp-server/.env file or export it:');
console.error('export ANTHROPIC_API_KEY=your_api_key_here');
process.exit(1);
}
// Initialize Anthropic API
console.log('🤖 Initializing Anthropic API...');
const anthropic = new AnthropicProvider('claude-sonnet-4-5-20250929', api_key);
// Prepare batch requests
console.log('📦 Preparing batch requests...');
const batch_requests: AnthropicBatchRequest[] = sections.map((slug, index) => {
const original = content[slug] || '';
const distilled = summaries[slug] || '';
return {
custom_id: `verify-${index}`,
params: {
model: anthropic.get_model_identifier(),
max_tokens: 4096,
messages: [
{
role: 'user',
content:
`${VERIFICATION_PROMPT}\n\n` +
`<original>${original}</original>\n\n` +
`<distilled>${distilled}</distilled>`,
},
],
temperature: 0,
},
};
});
// Create and process batch
console.log('🚀 Creating batch job...');
const batch_response = await anthropic.create_batch(batch_requests);
console.log(`✅ Batch created with ID: ${batch_response.id}`);
// Poll for completion
console.log('⏳ Waiting for batch to complete...');
let batch_status = await anthropic.get_batch_status(batch_response.id);
while (batch_status.processing_status === 'in_progress') {
const { succeeded, processing, errored } = batch_status.request_counts;
console.log(` Progress: ${succeeded} succeeded, ${processing} processing, ${errored} errored`);
await new Promise((resolve) => setTimeout(resolve, 5000));
batch_status = await anthropic.get_batch_status(batch_response.id);
}
console.log('✅ Batch processing completed!');
// Get results
if (!batch_status.results_url) {
throw new Error('Batch completed but no results URL available');
}
console.log('📥 Downloading results...');
const results = await anthropic.get_batch_results(batch_status.results_url);
// Process results
console.log('📊 Processing results...');
const verification_results: VerificationResult[] = [];
for (const result of results) {
const index = parseInt(result.custom_id.split('-')[1] ?? '0');
const slug = sections[index];
if (!slug) {
throw new Error(`Could not find slug for index ${index}`);
}
if (result.result.type !== 'succeeded' || !result.result.message) {
const error_msg = result.result.error?.message || 'Failed or no message';
console.error(` ❌ Failed to verify ${slug}: ${error_msg}`);
verification_results.push({
slug,
status: 'NOT_ACCURATE',
reasoning: `Verification failed: ${error_msg}`,
});
continue;
}
const output_content = result.result.message.content[0]?.text;
if (!output_content) {
console.error(` ❌ No text content in result for ${slug}`);
verification_results.push({
slug,
status: 'NOT_ACCURATE',
reasoning: 'No response from verification',
});
continue;
}
// Parse using regex instead of strict JSON parsing
const parsed = parse_verification_response(output_content);
if (!parsed) {
console.error(` ❌ Failed to parse response for ${slug}`);
console.error(` Raw response: ${output_content.slice(0, 200)}...`);
verification_results.push({
slug,
status: 'NOT_ACCURATE',
reasoning: `Failed to parse verification response: ${output_content.slice(0, 100)}`,
});
continue;
}
verification_results.push({
slug,
status: parsed.status,
reasoning: parsed.reasoning,
});
const emoji = parsed.status === 'ACCURATE' ? '✅' : '❌';
console.log(` ${emoji} ${slug}: ${parsed.status}`);
}
// Calculate statistics
const accurate_count = verification_results.filter((r) => r.status === 'ACCURATE').length;
const not_accurate_count = verification_results.filter((r) => r.status === 'NOT_ACCURATE').length;
// Write output
console.log('\n💾 Writing results to file...');
const output_dir = path.dirname(output_path);
await mkdir(output_dir, { recursive: true });
const output_data: VerificationOutput = {
generated_at: new Date().toISOString(),
model: 'claude-sonnet-4-5-20250929',
total_sections: sections.length,
verified_sections: sections.length,
accurate_count,
not_accurate_count,
results: verification_results,
};
// Validate output before writing
const validated = v.safeParse(verification_output_schema, output_data);
if (!validated.success) {
throw new Error(`Output validation failed: ${JSON.stringify(validated.issues, null, 2)}`);
}
await writeFile(output_path, JSON.stringify(output_data, null, 2), 'utf-8');
// Print summary
console.log('\n📊 Verification Summary:');
console.log(` Total sections: ${sections.length}`);
console.log(` Verified sections: ${sections.length}`);
console.log(
` ✅ Accurate: ${accurate_count} (${((accurate_count / sections.length) * 100).toFixed(1)}%)`,
);
console.log(
` ❌ Not Accurate: ${not_accurate_count} (${((not_accurate_count / sections.length) * 100).toFixed(1)}%)`,
);
if (not_accurate_count > 0) {
console.log('\n⚠ Sections with issues (first 10):');
verification_results
.filter((r) => r.status === 'NOT_ACCURATE')
.slice(0, 10)
.forEach((r) => {
console.log(` - ${r.slug}: ${r.reasoning}`);
});
if (not_accurate_count > 10) {
console.log(` ... and ${not_accurate_count - 10} more`);
}
console.log('\n💡 Run `pnpm show-verification-errors` to see all issues');
}
console.log(`\n✅ Results written to: ${output_path}`);
}
main().catch((error) => {
console.error('❌ Fatal error:', error);
process.exit(1);
});

View File

@@ -11,7 +11,6 @@ export const base_runes = [
export const nested_runes = [
'$state.raw',
'$state.snapshot',
'$state.eager',
'$effect.pre',
'$effect.tracking',
'$effect.pending',

View File

@@ -0,0 +1,875 @@
{
"generated_at": "2025-10-12T22:35:10.647Z",
"model": "claude-sonnet-4-5-20250929",
"total_sections": 173,
"verified_sections": 173,
"accurate_count": 159,
"not_accurate_count": 14,
"results": [
{
"slug": "cli/overview",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about the sv CLI tool, its usage with npx/pnpx, and the behavior of using local vs. downloaded versions, with only the acknowledgements section reasonably omitted."
},
{
"slug": "cli/faq",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including commands for each package manager, troubleshooting context, and references to the same GitHub issues, with only formatting changes and reasonable condensation."
},
{
"slug": "cli/sv-create",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, options, and examples from the original documentation with appropriate condensation and no factual errors or critical omissions."
},
{
"slug": "cli/sv-add",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including usage, options, and add-ons list, with only minor acceptable simplifications in wording and removal of non-critical elements like links and HTML comments."
},
{
"slug": "cli/sv-check",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, options, and examples from the original documentation with appropriate condensation and no factual errors or critical omissions."
},
{
"slug": "cli/sv-migrate",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including usage, migration types, and their purposes, with only minor formatting simplifications and no factual errors or critical omissions."
},
{
"slug": "cli/devtools-json",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the plugin's purpose, security note, alternatives, usage, and code example, with only minor formatting simplifications that preserve the core content."
},
{
"slug": "cli/drizzle",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup commands, features, database options, client options, and Docker configuration while maintaining factual accuracy through reasonable condensation."
},
{
"slug": "cli/eslint",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the tool's purpose, installation command, and key components installed, with only minor simplification of wording."
},
{
"slug": "cli/lucia",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the command, what it provides (SvelteKit + Drizzle auth setup following Lucia), and the demo option, with only minor formatting changes and reasonable simplifications."
},
{
"slug": "cli/mdsvex",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the definition, comparison to MDX, installation command, and configuration details, with only minor simplification of wording."
},
{
"slug": "cli/paraglide",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the library description, installation command, included features, and configuration options, with only minor formatting simplifications that preserve the original meaning."
},
{
"slug": "cli/playwright",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information from the original, with only minor formatting changes and reasonable simplification of the bullet points."
},
{
"slug": "cli/prettier",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the tool description, installation command, and what gets added to the project, with only minor rewording that preserves meaning."
},
{
"slug": "cli/storybook",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the installation command, automatic initialization, framework options, and key features like module mocking and link handling."
},
{
"slug": "cli/sveltekit-adapter",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including usage, adapter options with their purposes, and the example command, with only minor formatting simplifications and no factual errors or critical omissions."
},
{
"slug": "cli/tailwind",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup command, installed components, prettier integration, and plugin options, with only minor formatting changes and reasonable simplifications."
},
{
"slug": "cli/vitest",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the framework description, installation command, and the four key outcomes of running the command, with only minor rewording for brevity."
},
{
"slug": "kit/introduction",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential technical information, features, and links from the original, with only the introductory notes and some explanatory prose reasonably condensed."
},
{
"slug": "kit/creating-a-project",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the setup commands, core concepts of pages/routing/rendering, and editor recommendations, with only minor formatting changes and reasonable condensation of explanatory text."
},
{
"slug": "kit/project-types",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information from the original, preserving key concepts, links, and technical details while appropriately condensing explanations and formatting for brevity."
},
{
"slug": "kit/project-structure",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly names the file as \"instrumentation.server.js\" when the original clearly states it is \"tracing.server.js\" in the directory structure, though the description section does mention \"instrumentation.server.js\" creating ambiguity that should have been preserved."
},
{
"slug": "kit/web-standards",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the special fetch behavior, API interfaces, code examples, and usage contexts, with only minor formatting simplifications that preserve the original meaning."
},
{
"slug": "kit/routing",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including routing concepts, file types, code examples, and key behaviors, with appropriate condensation and no factual errors or critical omissions."
},
{
"slug": "kit/load",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including load function types, data flow, URL handling, fetch behavior, cookies, headers, parent data access, errors, redirects, streaming, parallel loading, rerunning logic, authentication implications, and getRequestEvent usage, with appropriate code examples preserved."
},
{
"slug": "kit/form-actions",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key concepts, code examples, and important notes from the original documentation, with appropriate condensation and no factual errors or misleading omissions."
},
{
"slug": "kit/page-options",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the five main page options (prerender, entries, ssr, csr, trailingSlash, config), their usage, code examples, and important warnings, with appropriate condensation but no factual errors or critical omissions."
},
{
"slug": "kit/state-management",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, preserves critical warnings and code examples, maintains accurate technical details, and only condenses explanatory text while keeping all key concepts intact."
},
{
"slug": "kit/remote-functions",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information including setup, all four function types (query, form, command, prerender), their usage patterns, validation, and key features like batching, single-flight mutations, and error handling, with no factual errors or critical omissions."
},
{
"slug": "kit/building-your-app",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the two-stage build process, the building flag usage with accurate code example, and preview limitations, with only minor formatting simplifications."
},
{
"slug": "kit/adapters",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the purpose of adapters, the list of official adapters, configuration method with code example, and platform-specific context details, with only minor formatting simplifications that don't alter meaning."
},
{
"slug": "kit/adapter-auto",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the adapter list, best practices, configuration limitations, and extension process, with appropriate simplification and no factual errors."
},
{
"slug": "kit/adapter-node",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information including installation, deployment, environment variables, options, graceful shutdown, socket activation, and custom server setup, with appropriate condensation of explanatory text while preserving critical technical details and code examples."
},
{
"slug": "kit/adapter-static",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including installation, configuration, options, and GitHub Pages setup, with appropriate condensation of explanatory text while preserving critical technical details and code examples."
},
{
"slug": "kit/single-page-apps",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including SPA setup, performance warnings, configuration steps, prerendering options, and Apache configuration, with appropriate simplifications and no factual errors."
},
{
"slug": "kit/adapter-cloudflare",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information, configuration options, code examples, and key concepts from the original documentation with appropriate condensation and no factual errors or critical omissions."
},
{
"slug": "kit/adapter-cloudflare-workers",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including deprecation notice, installation, configuration, deployment, runtime APIs, testing, and troubleshooting, with appropriate simplifications and no factual errors."
},
{
"slug": "kit/adapter-netlify",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including installation, configuration options, edge functions, Netlify-specific features, and troubleshooting, with only minor formatting simplifications and no factual errors or critical omissions."
},
{
"slug": "kit/adapter-vercel",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information, configuration options, warnings, and troubleshooting steps from the original, with appropriate condensation and formatting changes that preserve the core technical content."
},
{
"slug": "kit/writing-adapters",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the API structure, required/optional fields, adapt method tasks, and recommendations, with appropriate condensation and reorganization for clarity."
},
{
"slug": "kit/advanced-routing",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key concepts including rest parameters, optional parameters, matchers, sorting rules, encoding, and advanced layouts with correct code examples and essential notes, though condensed for brevity."
},
{
"slug": "kit/hooks",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key hooks, their purposes, parameters, and code examples while appropriately condensing explanatory text and preserving critical technical details."
},
{
"slug": "kit/errors",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including expected/unexpected errors, error handling, responses, type safety, and code examples, with only minor formatting simplifications that preserve the core concepts."
},
{
"slug": "kit/link-options",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key information, attribute values, code examples, and important warnings from the original documentation, with appropriate condensation but no factual errors or critical omissions."
},
{
"slug": "kit/service-workers",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup, the $service-worker module exports, the complete code example, development considerations, and alternative solutions, with only minor formatting changes and reasonable condensation of explanatory text."
},
{
"slug": "kit/server-only-modules",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the two methods for creating server-only modules, how the protection works, the import chain example, dynamic imports support, and the testing exception, with no factual errors or critical omissions."
},
{
"slug": "kit/snapshots",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the purpose, usage pattern, timing of capture/restore functions, serialization requirements, and the warning about large objects, with only minor formatting simplifications."
},
{
"slug": "kit/shallow-routing",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly states that shallow routing allows you to \"Navigate without triggering `load` functions or replacing page components\" when the original clearly states that navigating through history entries \"re-runs any `load` functions and replaces page components as necessary\" - shallow routing creates history entries WITHOUT navigating, not a way to navigate differently."
},
{
"slug": "kit/observability",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup, traced components, code examples, and important warnings, with only reasonable condensation of explanatory text."
},
{
"slug": "kit/packaging",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including package.json configuration, TypeScript handling, CLI options, and caveats, with appropriate condensation of examples while preserving technical accuracy."
},
{
"slug": "kit/auth",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the definitions, session vs token tradeoffs, integration points, and Lucia implementation details without any factual errors or critical omissions."
},
{
"slug": "kit/performance",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, performance tips, and technical details from the original, with appropriate condensation and formatting changes that preserve the core concepts and critical guidance."
},
{
"slug": "kit/icons",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the key points about CSS-based icons via Iconify and the warning against per-icon Svelte component libraries that slow down Vite, with appropriate links preserved."
},
{
"slug": "kit/images",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup, usage patterns, configuration details, and best practices, with appropriate condensation of explanatory text while preserving critical technical details and code examples."
},
{
"slug": "kit/accessibility",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including route announcements, focus management, lang attribute configuration, and further reading resources, with appropriate condensation but no factual errors or critical omissions."
},
{
"slug": "kit/seo",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including SSR defaults, performance considerations, URL normalization, manual setup requirements, and complete AMP implementation steps with accurate code examples, though reasonably condensed."
},
{
"slug": "kit/faq",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information, code examples, and key concepts from the original while appropriately condensing explanatory text and maintaining technical accuracy."
},
{
"slug": "kit/integrations",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including vitePreprocess functionality, TypeScript requirements, add-ons list, svelte-preprocess differences, and Vite plugins, with appropriate condensation and no factual errors."
},
{
"slug": "kit/debugging",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup steps, code examples, limitations, and references, with only minor formatting simplifications that preserve the core content."
},
{
"slug": "kit/migrating-to-sveltekit-2",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key breaking changes, code examples, and migration steps from the original documentation, with appropriate simplifications and no factual errors or critical omissions."
},
{
"slug": "kit/migrating",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key migration steps, API changes, file renames, and code examples from the original documentation without introducing factual errors or omitting critical information."
},
{
"slug": "kit/additional-resources",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all key information including FAQ links, example repositories, community resources, and support channels with appropriate guidance about searching first, using reasonable condensation without factual errors or critical omissions."
},
{
"slug": "kit/glossary",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, key concepts, default behaviors, configuration options, and important warnings from the original documentation without introducing factual errors or misleading statements."
},
{
"slug": "kit/@sveltejs-kit",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information from the original documentation, including function signatures, type definitions, important warnings, and version availability notes, with appropriate condensation of verbose descriptions while preserving critical technical details."
},
{
"slug": "kit/@sveltejs-kit-hooks",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the behavior of each option, the complete code example, expected output, and type signature with appropriate simplifications in formatting and structure."
},
{
"slug": "kit/@sveltejs-kit-node-polyfills",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the import path, function purpose, the specific APIs (crypto and File), and the TypeScript definition, with only minor formatting changes."
},
{
"slug": "kit/@sveltejs-kit-node",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including function signatures, parameters, and the version availability note, with only minor formatting changes and reasonable additions of clarifying descriptions."
},
{
"slug": "kit/@sveltejs-kit-vite",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all essential information including the import statement, function description, and TypeScript signature, with only minor formatting changes that don't affect accuracy."
},
{
"slug": "kit/$app-environment",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the import statement, the meaning of each exported constant, their types, and important caveats, with only minor wording simplifications that preserve accuracy."
},
{
"slug": "kit/$app-forms",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including function purposes, parameters, return types, code examples, and the detailed behavior of the enhance function's default and custom callback options."
},
{
"slug": "kit/$app-navigation",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key information, function signatures, and important behavioral details from the original documentation, with appropriate condensation that preserves essential meaning."
},
{
"slug": "kit/$app-paths",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including function signatures, usage examples, and deprecation notices, with only minor formatting simplifications that preserve the core content."
},
{
"slug": "kit/$app-server",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key information including function signatures, version availability, descriptions, and code examples, with only minor formatting simplifications that preserve the essential content."
},
{
"slug": "kit/$app-state",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the three state objects, their properties, usage examples, the critical runes vs legacy reactivity distinction, and server/browser behavior differences, with only minor formatting simplifications."
},
{
"slug": "kit/$app-stores",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including deprecation notices, functionality of each store, server/browser subscription constraints, and type signatures, with only minor formatting simplifications."
},
{
"slug": "kit/$app-types",
"status": "NOT_ACCURATE",
"reasoning": "The LayoutParams type definition incorrectly shows \"RouteParams\" instead of \"LayoutParams\" in the distilled version, which is a factual error copied from the original."
},
{
"slug": "kit/$env-dynamic-private",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the key rules about prefix filtering, client-side restriction, usage example, and the dev/prod behavior note."
},
{
"slug": "kit/$env-dynamic-public",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the public prefix requirement, client-side safety, network payload concern, recommendation to prefer static version, and preserves the accurate code example."
},
{
"slug": "kit/$env-static-private",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the static injection behavior, prefix filtering rules, server-only nature, and best practices, with appropriate simplification and reformatting."
},
{
"slug": "kit/$env-static-public",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the PUBLIC_ prefix requirement, configurability, client-side safety, build-time replacement, and preserves the code example accurately."
},
{
"slug": "kit/$lib",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about the $lib import alias, its default location, configurability, and includes the same code examples demonstrating its usage."
},
{
"slug": "kit/$service-worker",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the module availability, each export's type and purpose, development behavior, and configuration references without introducing factual errors or omitting critical details."
},
{
"slug": "kit/configuration",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential configuration options, defaults, code examples, and important notes from the original documentation, with appropriate condensation and no factual errors or critical omissions."
},
{
"slug": "kit/cli",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including Vite CLI commands, svelte-kit sync functionality, and automatic execution, with only minor simplifications that preserve meaning."
},
{
"slug": "kit/types",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including generated types, helper types, setup requirements, $lib aliases, and app.d.ts interfaces, with appropriate code examples and version-specific details preserved."
},
{
"slug": "mcp/overview",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all critical information including setup options, the complete usage prompt, and tool descriptions, with only minor formatting simplifications that don't alter meaning."
},
{
"slug": "mcp/local-setup",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including installation commands, configuration examples for each client, and maintains factual accuracy with appropriate condensation of instructional text."
},
{
"slug": "mcp/remote-setup",
"status": "ACCURATE",
"reasoning": "The distilled version correctly preserves all essential setup instructions, commands, and configuration details for each client while appropriately condensing explanatory text and formatting."
},
{
"slug": "mcp/tools",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all four tools and their essential functions, with only minor formatting changes and reasonable condensation of descriptions."
},
{
"slug": "mcp/resources",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about the doc-section resource including URI format, return type, and use case, with only minor formatting changes and reasonable simplification."
},
{
"slug": "mcp/prompts",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version omits critical information about the extensive list of available documentation paths with their specific use cases, which is essential for the LLM to know when to invoke the get_documentation tool with the correct path parameter."
},
{
"slug": "svelte/overview",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about Svelte being a compiler-based framework, preserves the complete code example, and accurately notes the key syntax detail about event handlers and SvelteKit usage."
},
{
"slug": "svelte/getting-started",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including setup commands, alternatives, tooling options, and help resources without introducing factual errors or omitting critical details."
},
{
"slug": "svelte/svelte-files",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including component structure, script behaviors, module-level logic, scoping rules, and includes the key code examples, with only minor formatting simplifications and removal of non-critical notes."
},
{
"slug": "svelte/svelte-js-files",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the file types, their behavior, use cases, and the critical limitation about exporting reassigned state."
},
{
"slug": "svelte/what-are-runes",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information about runes including their purpose, syntax, and three key characteristics, with only the etymology note and legacy information reasonably omitted."
},
{
"slug": "svelte/$state",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including key concepts, code examples, gotchas, and the two options for sharing state across modules, with appropriate simplifications and no factual errors."
},
{
"slug": "svelte/$derived",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key concepts including $derived, $derived.by, dependencies, overriding values, reactivity behavior, destructuring, and update propagation with correct code examples and essential details preserved."
},
{
"slug": "svelte/$effect",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key concepts, correctly represents the code examples, maintains critical warnings about when not to use effects, and preserves the essential technical details about lifecycle, dependencies, and the various effect runes."
},
{
"slug": "svelte/$props",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including props usage, fallback values, renaming, rest props, updating behavior with warnings about mutation, type safety examples, and $props.id() functionality, with appropriate condensation of examples while preserving core concepts."
},
{
"slug": "svelte/$bindable",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the bidirectional data flow concept, $bindable syntax, usage examples, fallback values, and the warning about sparing use, with only minor formatting changes."
},
{
"slug": "svelte/$inspect",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including development-only behavior, deep reactivity tracking, the `.with()` method signature, `$inspect.trace()` requirements, and preserves critical details like the first-statement requirement and optional label parameter."
},
{
"slug": "svelte/$host",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about the $host rune, preserves the code examples accurately, and adds helpful key points without introducing any factual errors or contradictions."
},
{
"slug": "svelte/basic-markup",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including tags, attributes, props, events, delegation, text expressions, and comments with accurate technical details and no misleading omissions."
},
{
"slug": "svelte/if",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, examples, and the note about blocks wrapping elements or text, with only minor formatting improvements."
},
{
"slug": "svelte/each",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, keyed blocks, destructuring, itemless iteration, and else clauses with appropriate examples and explanations."
},
{
"slug": "svelte/key",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, core behavior (destroy/recreate on change), and both key use cases (component reinstantiation and transition replay) with accurate code examples."
},
{
"slug": "svelte/await",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly states that omitting the catch block is a \"shorthand pattern\" when the original shows this requires omitting the initial pending block as well, and it fails to mention that the catch block can be omitted while keeping the pending block."
},
{
"slug": "svelte/snippet",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, scope rules, component passing methods, TypeScript typing, exporting capabilities, and the key restrictions, with appropriate condensation of examples while preserving core concepts."
},
{
"slug": "svelte/@render",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all key information including syntax, code examples, optional chaining usage, and fallback patterns with only minor formatting changes and reasonable simplifications."
},
{
"slug": "svelte/@html",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly shows `article :global` (with a space) instead of `article :global(*)` or the nested syntax shown in the original, which would target different elements than intended."
},
{
"slug": "svelte/@attach",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including basic usage, attachment factories, inline attachments, component passing, reactivity control, and utility functions, with appropriate code examples and key concepts preserved."
},
{
"slug": "svelte/@const",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about {@const} tag usage, its purpose, code example, and placement restrictions, with only minor formatting differences."
},
{
"slug": "svelte/@debug",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the core functionality, syntax rules, valid/invalid examples, and the no-arguments behavior, with only minor formatting improvements."
},
{
"slug": "svelte/bind",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, binding types, version-specific features, and important notes/warnings, with appropriate condensation of examples while preserving core concepts."
},
{
"slug": "svelte/use",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the note about attachments, action syntax, argument usage, the key behavior that actions don't re-run on argument changes, and typing details, with only minor formatting simplifications."
},
{
"slug": "svelte/transition",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including transition behavior, local vs global distinctions, parameters, custom functions with css/tick details, and transition events, with appropriate condensation but no factual errors or critical omissions."
},
{
"slug": "svelte/in-and-out",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the key concepts of non-bidirectional behavior, simultaneous play of in/out transitions, and restart behavior when aborted, with the same code example preserved."
},
{
"slug": "svelte/animate",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including animation triggers, usage patterns, custom function signatures, and the distinction between css and tick methods, with appropriate simplifications and no factual errors."
},
{
"slug": "svelte/style",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including basic usage, expressions, shorthand form, multiple styles, important modifier, and precedence rules with accurate code examples."
},
{
"slug": "svelte/class",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the two ways to set classes, version-specific features, code examples, and the recommendation to prefer the class attribute over the class: directive."
},
{
"slug": "svelte/await-expressions",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the experimental flag configuration, synchronized updates behavior, concurrency rules, loading state handling, error handling, SSR support, and caveats, with appropriate code examples preserved."
},
{
"slug": "svelte/scoped-styles",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including scoped styles, specificity increases, :where() usage, and scoped keyframes with accurate technical details and preserved code examples."
},
{
"slug": "svelte/global-styles",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all essential information including syntax, examples, and key concepts about global styling and keyframes, with only minor formatting changes and removal of a non-critical note about alternative selector syntax."
},
{
"slug": "svelte/custom-properties",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, desugaring behavior, SVG handling, var() usage with fallbacks, inheritance, and the CSS selector gotcha, with only minor formatting changes."
},
{
"slug": "svelte/nested-style-elements",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key information including the one top-level style tag limit, nested style tag behavior, lack of scoping/processing for nested tags, and preserves the illustrative code example."
},
{
"slug": "svelte/svelte-boundary",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly states that boundaries only catch errors during \"top-level $effect\" when the original says \"running effects\" more broadly, and it omits the critical note about the playground's built-in boundary behavior for the pending snippet."
},
{
"slug": "svelte/svelte-window",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, rules, event listener usage, bindable properties with their readonly/writable distinctions, and the important scrolling behavior note."
},
{
"slug": "svelte/svelte-document",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, usage constraints, event handling, actions support, and the four readonly bindable properties without any factual errors or critical omissions."
},
{
"slug": "svelte/svelte-body",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including syntax, usage, supported features (events and actions), and the critical constraint about top-level placement."
},
{
"slug": "svelte/svelte-head",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including functionality, SSR behavior, placement restrictions, and preserves the code example accurately."
},
{
"slug": "svelte/svelte-element",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including usage, limitations, void element behavior, nullish handling, namespace requirements, and valid tag restrictions without any factual errors or critical omissions."
},
{
"slug": "svelte/svelte-options",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version omits critical information about deprecated Svelte 4 options (immutable and accessors) and removes important reference links to the compiler section, Legacy APIs section, and custom elements component options documentation."
},
{
"slug": "svelte/stores",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information including the $ prefix syntax, when to use stores vs runes in Svelte 5, all API methods with correct examples, and the store contract requirements without any factual errors or critical omissions."
},
{
"slug": "svelte/context",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly shows `counter.count = 0` in the \"Correct\" example when the original uses `+++counter.count = 0+++` (which appears to be markup indicating emphasis, but the actual code should be `counter.count = 0`), and more critically, it omits the important context about when Parent.svelte renders Child.svelte as part of a children snippet, which is described as \"particularly useful\" in the original."
},
{
"slug": "svelte/lifecycle-hooks",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including lifecycle concepts, API usage, server-side behavior notes, cleanup patterns, the deprecation of beforeUpdate/afterUpdate, and the chat autoscroll example with accurate code."
},
{
"slug": "svelte/imperative-component-api",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including API signatures, key behavioral differences from Svelte 4, return values, and critical notes about effects and flushSync, with only minor formatting improvements."
},
{
"slug": "svelte/testing",
"status": "ACCURATE",
"reasoning": "The distilled version preserves all critical information, code examples, and key concepts from the original while appropriately condensing explanatory text and maintaining technical accuracy."
},
{
"slug": "svelte/typescript",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including TypeScript setup, limitations, configuration requirements, typing patterns, and code examples, with appropriate condensation but no factual errors or critical omissions."
},
{
"slug": "svelte/custom-elements",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all essential information including lifecycle behavior, component options, usage patterns, and caveats, with appropriate condensation and preserved code examples."
},
{
"slug": "svelte/v4-migration-guide",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key migration information, requirements, code examples, and breaking changes from the original documentation, with appropriate condensation and formatting that preserves the essential technical details."
},
{
"slug": "svelte/v5-migration-guide",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key migration information, breaking changes, and code examples from the original documentation, with appropriate condensation while preserving critical technical details and warnings."
},
{
"slug": "svelte/faq",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information from the original, with appropriate condensation of explanations while preserving key facts, links, code examples, and critical details like the Svelte Native limitation in Svelte 5."
},
{
"slug": "svelte/svelte",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information, properly marks deprecated features, preserves critical code examples and type signatures, and accurately represents the migration guidance from Svelte 4 to Svelte 5."
},
{
"slug": "svelte/svelte-action",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly states \"Use `use:` directive to apply them\" which is not mentioned in the original documentation and could be misleading since the original explicitly states actions have been superseded by attachments."
},
{
"slug": "svelte/svelte-animate",
"status": "ACCURATE",
"reasoning": "The distilled version correctly preserves all key information including the flip function signature, its purpose, the FLIP acronym explanation, and complete interface definitions for AnimationConfig and FlipParams."
},
{
"slug": "svelte/svelte-attachments",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version omits the critical \"Available since 5.29\" version information for createAttachmentKey, which is essential for developers to know compatibility requirements."
},
{
"slug": "svelte/svelte-compiler",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including function signatures, key options with defaults, type definitions, and important notes about deprecations and version changes, with appropriate simplifications that preserve meaning."
},
{
"slug": "svelte/svelte-easing",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the import path, function signature, all available easing functions with their variants, and adds helpful context about the parameter/return value ranges and easing types without introducing any factual errors."
},
{
"slug": "svelte/svelte-events",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential functionality, key benefit, and API usage, with the type signatures reasonably simplified into a single generic form that encompasses all the specific overloads shown in the original."
},
{
"slug": "svelte/svelte-legacy",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key functions, their purposes, and type signatures while appropriately condensing descriptions and maintaining the deprecated/temporary nature of the module."
},
{
"slug": "svelte/svelte-motion",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including API signatures, key properties, methods, availability dates, deprecation notices, and code examples, with appropriate simplifications that preserve the core concepts."
},
{
"slug": "svelte/svelte-reactivity-window",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the reactive nature, usage examples, all exports, server-side behavior, and critical implementation details like browser differences and requestAnimationFrame updates."
},
{
"slug": "svelte/svelte-reactivity",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key information, including API signatures, critical warnings (SSR/hydration, deep reactivity), and complete code examples, with only minor formatting simplifications."
},
{
"slug": "svelte/svelte-server",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version incorrectly simplifies the type signature by removing the conditional types that make props required when the component has required props (the `{} extends Props` conditional logic and the two different function overloads)."
},
{
"slug": "svelte/svelte-store",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential functions, their signatures, and key type definitions with appropriate simplifications to descriptions while maintaining technical accuracy."
},
{
"slug": "svelte/svelte-transition",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including function signatures, parameters, behavior descriptions, and type definitions, with only minor formatting simplifications and reasonable condensation of explanatory text."
},
{
"slug": "svelte/compiler-errors",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key error messages, their meanings, and critical code examples while appropriately condensing the content without introducing factual errors or misleading information."
},
{
"slug": "svelte/compiler-warnings",
"status": "ACCURATE",
"reasoning": "The distilled version accurately captures all key warnings with their essential information, code examples, and solutions, using appropriate condensation while preserving critical details for developers."
},
{
"slug": "svelte/runtime-errors",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version contains a syntax error in the effect_update_depth_exceeded section with an extra closing brace (`});` appears twice), which would mislead developers trying to understand the code example."
},
{
"slug": "svelte/runtime-warnings",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key warnings with their essential explanations and code examples, using reasonable condensation while preserving critical technical details and fixes."
},
{
"slug": "svelte/legacy-overview",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the key information about Svelte 5 changes, the two modes, and the reference to v4 documentation, with only minor simplifications that preserve the essential meaning."
},
{
"slug": "svelte/legacy-let",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the auto-reactive nature of top-level variables, the array methods gotcha, and preserves the code examples accurately, with only minor formatting changes for condensation."
},
{
"slug": "svelte/legacy-reactive-assignments",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including basic usage, topological ordering, dependencies, gotchas, and browser-only code, with appropriate simplifications and no factual errors."
},
{
"slug": "svelte/legacy-export-let",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including prop declaration syntax, default value behavior, the critical difference about undefined values not reverting, component exports, and prop renaming, with appropriate code examples preserved."
},
{
"slug": "svelte/legacy-$$props-and-$$restProps",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the distinction between legacy and runes mode, the definitions of $$props and $$restProps, the complete code example, and the performance warning."
},
{
"slug": "svelte/legacy-on",
"status": "NOT_ACCURATE",
"reasoning": "The distilled version omits the legacy createEventDispatcher implementation details and example usage that are still part of the current documentation, which could mislead developers who need to work with existing code using that pattern."
},
{
"slug": "svelte/legacy-slots",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including basic slots, named slots, fallback content, and passing data to slots, with appropriate code examples and no factual errors or critical omissions."
},
{
"slug": "svelte/legacy-$$slots",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential information about $$slots in legacy mode, preserves the code examples intact, and appropriately notes the runes mode alternative, with only minor formatting changes."
},
{
"slug": "svelte/legacy-svelte-fragment",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures the essential functionality, preserves the complete code examples, and accurately conveys the Svelte 5+ obsolescence note, with only minor acceptable formatting changes."
},
{
"slug": "svelte/legacy-svelte-component",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all key information including the legacy mode behavior, runes mode alternative, and the falsy condition, with appropriate reorganization for clarity."
},
{
"slug": "svelte/legacy-svelte-self",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including the recursive functionality, the requirement to prevent infinite loops, the code example, and the obsolescence note with the self-import alternative."
},
{
"slug": "svelte/legacy-component-api",
"status": "ACCURATE",
"reasoning": "The distilled version correctly captures all essential information including API methods, options tables, key behaviors (async vs sync updates), and Svelte 5 migration notes, with appropriate condensation of explanatory text while preserving critical technical details."
}
]
}

File diff suppressed because one or more lines are too long

View File

@@ -17,24 +17,8 @@ export const summary_data_schema = v.object({
model: v.string(),
total_sections: v.number(),
successful_summaries: v.number(),
failed_summaries: v.number(),
summaries: v.record(v.string(), v.string()),
errors: v.optional(
v.array(
v.object({
section: v.string(),
error: v.string(),
}),
),
),
download_errors: v.optional(
v.array(
v.object({
section: v.string(),
error: v.string(),
}),
),
),
content: v.record(v.string(), v.string()),
});
export const anthropic_batch_request_schema = v.object({

View File

@@ -8,7 +8,6 @@ export function add_autofixers_issues(
code: string,
desired_svelte_version: number,
filename = 'Component.svelte',
async = false,
) {
const parsed = parse(code, filename);
@@ -16,7 +15,7 @@ export function add_autofixers_issues(
for (const autofixer of Object.values(autofixers)) {
walk(
parsed.ast as unknown as Node,
{ output: content, parsed, desired_svelte_version, async },
{ output: content, parsed, desired_svelte_version },
autofixer,
);
}

View File

@@ -7,7 +7,6 @@ export function add_compile_issues(
code: string,
desired_svelte_version: number,
filename = 'Component.svelte',
async = false,
) {
let compile = compile_component;
const extension = extname(filename);
@@ -28,7 +27,6 @@ export function add_compile_issues(
filename: filename || 'Component.svelte',
generate: false,
runes: desired_svelte_version >= 5,
experimental: { async },
});
for (const warning of compilation_result.warnings) {

View File

@@ -35,7 +35,6 @@ function base_config(svelte_config: Config): ESLint.Options['baseConfig'] {
'svelte/prefer-writable-derived': 'warn',
'svelte/require-event-dispatcher-types': 'warn',
'svelte/require-store-reactive-access': 'warn',
'svelte/no-inspect': 'off',
},
languageOptions: {
@@ -52,7 +51,7 @@ function base_config(svelte_config: Config): ESLint.Options['baseConfig'] {
];
}
function get_linter(version: number, async = false) {
function get_linter(version: number) {
if (version < 5) {
return (svelte_4_linter ??= new ESLint({
overrideConfigFile: true,
@@ -68,7 +67,6 @@ function get_linter(version: number, async = false) {
baseConfig: base_config({
compilerOptions: {
runes: true,
experimental: { async },
},
}),
}));
@@ -79,9 +77,8 @@ export async function add_eslint_issues(
code: string,
desired_svelte_version: number,
filename = 'Component.svelte',
async = false,
) {
const eslint = get_linter(desired_svelte_version, async);
const eslint = get_linter(desired_svelte_version);
const results = await eslint.lintText(code, { filePath: filename || './Component.svelte' });
for (const message of results[0]?.messages ?? []) {

View File

@@ -7,7 +7,6 @@ export type AutofixerState = {
output: { issues: string[]; suggestions: string[] };
parsed: ParseResult;
desired_svelte_version: number;
async?: boolean;
};
export type Autofixer = Visitors<Node | AST.SvelteNode, AutofixerState>;

View File

@@ -1,23 +1,19 @@
import type { SvelteMcp } from '../../index.js';
import * as v from 'valibot';
import { format_sections_list } from '../../utils.js';
import { icons } from '../../icons/index.js';
import { prompt } from 'tmcp/utils';
/**
* Function that actually generates the prompt string. You can use this in the MCP server handler to generate the prompt, it can accept arguments
* if needed (it will always be invoked manually so it's up to you to provide the arguments).
*/
function svelte_task(available_docs: string, task: string) {
return `You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool \`get-documentation\` with one of the following paths. However: before invoking the \`get-documentation\` tool, try to answer the users query using your own knowledge and the \`svelte-autofixer\` tool. Be mindful of how many section you request, since it is token-intensive!
return `You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool \`get_documentation\` with one of the following paths:
<available-docs>
${available_docs}
</available-docs>
These are the available documentation sections that \`list-sections\` will return, you do not need to call it again.
Every time you write a Svelte component or a Svelte module you MUST invoke the \`svelte-autofixer\` tool providing the code. The tool will return a list of issues or suggestions. If there are any issues or suggestions you MUST fix them and call the tool again with the updated code. You MUST keep doing this until the tool returns no issues or suggestions. Only then you can return the code to the user.
This is the task you will work on:
@@ -68,15 +64,21 @@ export function setup_svelte_task(server: SvelteMcp) {
};
},
},
icons,
},
async ({ task }) => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-task');
}
const available_docs = await format_sections_list();
return prompt.text(svelte_task(available_docs, task));
return {
messages: [
{
role: 'user',
content: {
type: 'text',
text: svelte_task(available_docs, task),
},
},
],
};
},
);
}

View File

@@ -1,7 +1,5 @@
import type { SvelteMcp } from '../../index.js';
import { get_sections, fetch_with_timeout } from '../../utils.js';
import { icons } from '../../icons/index.js';
import { resource } from 'tmcp/utils';
export async function list_sections(server: SvelteMcp) {
const sections = await get_sections();
@@ -44,23 +42,23 @@ export async function list_sections(server: SvelteMcp) {
},
},
uri: 'svelte://{/slug*}.md',
icons,
},
async (uri, { slug }) => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(
server.ctx.sessionId,
'svelte-doc-section',
Array.isArray(slug) ? slug.join(',') : slug,
);
}
const section = sections.find((section) => {
return slug === section.slug;
});
if (!section) throw new Error(`Section not found: ${slug}`);
const response = await fetch_with_timeout(section.url);
const content = await response.text();
return resource.text(uri, content);
return {
contents: [
{
uri,
type: 'text',
text: content,
},
],
};
},
);
}

View File

@@ -1,141 +1,160 @@
import type { SvelteMcp } from '../../index.js';
import * as v from 'valibot';
import { get_sections, fetch_with_timeout, format_sections_list } from '../../utils.js';
import {
get_sections,
fetch_with_timeout,
format_sections_list,
get_distilled_content,
} from '../../utils.js';
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.js';
import { icons } from '../../icons/index.js';
import { tool } from 'tmcp/utils';
const get_documentation_schema = v.object({
section: v.pipe(
v.union([v.string(), v.array(v.string())]),
v.description(
'The section name(s) to retrieve. Can search by title (e.g., "$state", "load functions") or file path (e.g., "cli/overview"). Supports single string and array of strings',
),
),
});
export async function get_documentation_handler({
section,
}: v.InferInput<typeof get_documentation_schema>) {
let sections: string[];
if (Array.isArray(section)) {
sections = section.filter((s): s is string => typeof s === 'string');
} else if (
typeof section === 'string' &&
section.trim().startsWith('[') &&
section.trim().endsWith(']')
) {
try {
const parsed = JSON.parse(section);
if (Array.isArray(parsed)) {
sections = parsed.filter((s): s is string => typeof s === 'string');
} else {
sections = [section];
}
} catch {
sections = [section];
}
} else if (typeof section === 'string') {
sections = [section];
} else {
sections = [];
}
const available_sections = await get_sections();
const settled_results = await Promise.allSettled(
sections.map(async (requested_section) => {
const matched_section = available_sections.find(
(s) =>
s.title.toLowerCase() === requested_section.toLowerCase() ||
s.slug === requested_section ||
s.url === requested_section,
);
if (matched_section) {
try {
const response = await fetch_with_timeout(matched_section.url);
if (response.ok) {
const content = await response.text();
return { success: true, content: `## ${matched_section.title}\n\n${content}` };
} else {
return {
success: false,
content: `## ${matched_section.title}\n\nError: Could not fetch documentation (HTTP ${response.status})`,
};
}
} catch (error) {
return {
success: false,
content: `## ${matched_section.title}\n\nError: Failed to fetch documentation - ${error}`,
};
}
} else {
return {
success: false,
content: `## ${requested_section}\n\nError: Section not found.`,
};
}
}),
);
const results = settled_results.map((result) => {
if (result.status === 'fulfilled') {
return result.value;
} else {
return {
success: false,
content: `Error: Couldn't fetch - ${result.reason}`,
};
}
});
const has_any_success = results.some((result) => result.success);
let final_text = results.map((r) => r.content).join('\n\n---\n\n');
if (!has_any_success) {
const formatted_sections = await format_sections_list();
final_text += `\n\n---\n\n${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`;
}
return final_text;
}
export function get_documentation(server: SvelteMcp) {
server.tool(
{
name: 'get-documentation',
description:
'Retrieves full documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "cli/overview"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on. Before calling this tool, try to implement Svelte components using your own knowledge and the `svelte-autofixer` tool, since calling this tool is token intensive.',
schema: get_documentation_schema,
annotations: {
title: 'Get Documentation',
destructiveHint: false,
readOnlyHint: true,
openWorldHint: false,
},
icons,
'Retrieves documentation content for Svelte 5 or SvelteKit sections. Supports flexible search by title (e.g., "$state", "routing") or file path (e.g., "cli/overview"). Can accept a single section name or an array of sections. Before running this, make sure to analyze the users query, as well as the output from list-sections (which should be called first). Then ask for ALL relevant sections the user might require. For example, if the user asks to build anything interactive, you will need to fetch all relevant runes, and so on.',
schema: v.object({
section: v.pipe(
v.union([v.string(), v.array(v.string())]),
v.description(
'The section name(s) to retrieve. Can search by title (e.g., "$state", "load functions") or file path (e.g., "cli/overview"). Supports single string and array of strings',
),
),
use_distilled: v.optional(
v.pipe(
v.boolean(),
v.description(
'If true (default), returns condensed distilled versions of the documentation to optimize context size. Set to false ONLY if the user asks to fetch full documentation.',
),
),
true,
),
}),
},
async ({ section }) => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(server.ctx.sessionId, 'get-documentation');
}
try {
const content = await get_documentation_handler({ section });
return tool.text(content);
} catch (e) {
const error = e as Error;
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(
server.ctx.sessionId,
'get-documentation-error',
error.message,
);
async ({ section, use_distilled = true }) => {
let sections: string[];
if (Array.isArray(section)) {
sections = section.filter((s): s is string => typeof s === 'string');
} else if (
typeof section === 'string' &&
section.trim().startsWith('[') &&
section.trim().endsWith(']')
) {
try {
const parsed = JSON.parse(section);
if (Array.isArray(parsed)) {
sections = parsed.filter((s): s is string => typeof s === 'string');
} else {
sections = [section];
}
} catch {
sections = [section];
}
return tool.error(error.message);
} else if (typeof section === 'string') {
sections = [section];
} else {
sections = [];
}
const available_sections = await get_sections();
// Sections that are never distilled, since they contain reference information where things might go missing in distillation
const ALWAYS_FULL_SECTIONS = [
'kit/@sveltejs-kit',
'svelte/v5-migration-guide',
'kit/remote-functions',
'kit/configuration',
'mcp/prompts',
'svelte/compiler-warnings',
'svelte/svelte-compiler',
'svelte/compiler-errors',
'svelte/svelte',
];
const settled_results = await Promise.allSettled(
sections.map(async (requested_section) => {
const matched_section = available_sections.find(
(s) =>
s.title.toLowerCase() === requested_section.toLowerCase() ||
s.slug === requested_section ||
s.url === requested_section,
);
if (matched_section) {
// Force full documentation for specific sections
const should_use_distilled =
use_distilled && !ALWAYS_FULL_SECTIONS.includes(matched_section.slug);
console.log(
`Fetching documentation for section "${matched_section.title}" (${should_use_distilled ? 'distilled' : 'full'})`,
);
if (should_use_distilled) {
const distilled = get_distilled_content(matched_section.slug);
if (distilled) {
return {
success: true,
content: `## ${matched_section.title}\n\n${distilled}`,
};
}
// If no distilled content, fall through to fetch full content
}
try {
const response = await fetch_with_timeout(matched_section.url);
if (response.ok) {
const content = await response.text();
return { success: true, content: `## ${matched_section.title}\n\n${content}` };
} else {
return {
success: false,
content: `## ${matched_section.title}\n\nError: Could not fetch documentation (HTTP ${response.status})`,
};
}
} catch (error) {
return {
success: false,
content: `## ${matched_section.title}\n\nError: Failed to fetch documentation - ${error}`,
};
}
} else {
return {
success: false,
content: `## ${requested_section}\n\nError: Section not found.`,
};
}
}),
);
const results = settled_results.map((result) => {
if (result.status === 'fulfilled') {
return result.value;
} else {
return {
success: false,
content: `Error: Couldn't fetch - ${result.reason}`,
};
}
});
const has_any_success = results.some((result) => result.success);
let final_text = results.map((r) => r.content).join('\n\n---\n\n');
if (!has_any_success) {
const formatted_sections = await format_sections_list();
final_text += `\n\n---\n\n${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`;
}
return {
content: [
{
type: 'text',
text: final_text,
},
],
};
},
);
}

View File

@@ -1,4 +0,0 @@
export { get_documentation_handler } from './get-documentation.js';
export { list_sections_handler } from './list-sections.js';
export { svelte_autofixer_handler } from './svelte-autofixer.js';
export { playground_link_handler } from './playground-link.js';

View File

@@ -1,4 +1,4 @@
export { get_documentation } from './get-documentation.js';
export { list_sections } from './list-sections.js';
export { svelte_autofixer } from './svelte-autofixer.js';
export { playground_link } from './playground-link.js';
export * from './get-documentation.js';
export * from './list-sections.js';
export * from './svelte-autofixer.js';
export * from './playground-link.js';

View File

@@ -1,14 +1,6 @@
import type { SvelteMcp } from '../../index.js';
import { format_sections_list } from '../../utils.js';
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.js';
import { icons } from '../../icons/index.js';
import { tool } from 'tmcp/utils';
export async function list_sections_handler() {
const formatted_sections = await format_sections_list();
return `${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`;
}
export function list_sections(server: SvelteMcp) {
server.tool(
@@ -16,32 +8,18 @@ export function list_sections(server: SvelteMcp) {
name: 'list-sections',
description:
'Lists all available Svelte 5 and SvelteKit documentation sections in a structured format. Each section includes a "use_cases" field that describes WHEN this documentation would be useful. You should carefully analyze the use_cases field to determine which sections are relevant for the user\'s query. The use_cases contain comma-separated keywords describing project types (e.g., "e-commerce", "blog"), features (e.g., "authentication", "forms"), components (e.g., "slider", "modal"), development stages (e.g., "deployment", "testing"), or "always" for fundamental concepts. Match these use_cases against the user\'s intent - for example, if building an e-commerce site, fetch sections with use_cases containing "e-commerce", "product listings", "shopping cart", etc. If building a slider, look for "slider", "carousel", "animation", etc. Returns sections as "* title: [section_title], use_cases: [use_cases], path: [file_path]". Always run list-sections FIRST for any Svelte query, then analyze ALL use_cases to identify relevant sections, and finally use get_documentation to fetch ALL relevant sections at once.',
annotations: {
title: 'List Sections',
destructiveHint: false,
readOnlyHint: true,
openWorldHint: false,
},
icons,
},
async () => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(server.ctx.sessionId, 'list-sections');
}
try {
const content = await list_sections_handler();
return tool.text(content);
} catch (e) {
const error = e as Error;
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(
server.ctx.sessionId,
'list-sections-error',
error.message,
);
}
return tool.error(error.message);
}
const formatted_sections = await format_sections_list();
return {
content: [
{
type: 'text',
text: `${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`,
},
],
};
},
);
}

View File

@@ -1,102 +0,0 @@
import { InMemoryTransport } from '@tmcp/transport-in-memory';
import { beforeEach, describe, expect, it } from 'vitest';
import { server } from '../../index.js';
const transport = new InMemoryTransport(server);
let session: ReturnType<typeof transport.session>;
describe('playground-link tool', () => {
beforeEach(async () => {
session = transport.session();
await session.initialize(
'2025-06-18',
{},
{
name: 'test-client',
version: '1.0.0',
},
);
});
it('should create a playground link if App.svelte is present', async () => {
const result = await session.callTool<{ url: string }>('playground-link', {
name: 'My Playground',
tailwind: false,
files: {
'App.svelte': `Hi there!`,
},
});
expect(result.structuredContent).toBeDefined();
expect(result.structuredContent?.url).toBeDefined();
// Verify URL structure rather than exact match (gzip compression can vary by platform)
expect(result.structuredContent?.url).toMatch(/^https:\/\/svelte\.dev\/playground#H4sIA/);
expect(result.structuredContent?.url).toContain('svelte.dev/playground');
});
it('should have a content with the stringified version of structured content and an ui resource', async () => {
const result = await session.callTool<{ url: string }>('playground-link', {
name: 'My Playground',
tailwind: false,
files: {
'App.svelte': `Hi there!`,
},
});
expect(result.structuredContent).toBeDefined();
expect(result.content).toStrictEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'text',
text: JSON.stringify(result.structuredContent),
}),
]),
);
// Verify resource structure without exact URL match (gzip compression can vary by platform)
expect(result.content).toStrictEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'resource',
resource: expect.objectContaining({
uri: 'ui://svelte/playground-link',
mimeType: 'text/html;profile=mcp-app',
_meta: { 'mcpui.dev/ui-preferred-frame-size': ['100%', '1200px'] },
text: expect.stringMatching(/^https:\/\/svelte\.dev\/playground\/embed#H4sIA/),
}),
}),
]),
);
});
it('should have tool _meta with resource URI for MCP Apps hosts', async () => {
const tools = await session.listTools();
const playground_tool = tools.tools.find((t) => t.name === 'playground-link');
expect(playground_tool).toBeDefined();
expect(playground_tool?._meta).toStrictEqual({
ui: { resourceUri: 'ui://svelte/playground-link' },
});
});
it('should expose a resource for MCP Apps hosts', async () => {
const resources = await session.listResources();
const playground_resource = resources.resources.find(
(r) => r.uri === 'ui://svelte/playground-link',
);
expect(playground_resource).toBeDefined();
expect(playground_resource?.name).toBe('playground-link-ui');
});
it('should not create a playground link if App.svelte is missing', async () => {
const result = await session.callTool<{ url: string }>('playground-link', {
name: 'My Playground',
tailwind: false,
files: {
'Something.svelte': `Hi there!`,
},
});
expect(result.isError).toBe(true);
expect(result.content?.[0]).toStrictEqual({
type: 'text',
text: 'The files must contain an App.svelte file as the entry point',
});
});
});

View File

@@ -1,8 +1,5 @@
import { createUIResource } from '@mcp-ui/server';
import { tool } from 'tmcp/utils';
import * as v from 'valibot';
import { icons } from '../../icons/index.js';
import type { SvelteMcp } from '../../index.js';
import * as v from 'valibot';
async function compress_and_encode_text(input: string) {
const reader = new Blob([input]).stream().pipeThrough(new CompressionStream('gzip')).getReader();
@@ -30,232 +27,86 @@ type File = {
text: boolean;
};
const playground_link_schema = v.object({
name: v.pipe(
v.string(),
v.description('The name of the Playground, it should reflect the user task'),
),
tailwind: v.pipe(
v.boolean(),
v.description(
"If the code requires Tailwind CSS to work...only send true if it it's using tailwind classes in the code",
),
),
files: v.pipe(
v.record(v.string(), v.string()),
v.description(
"An object where all the keys are the filenames (with extensions) and the values are the file content. For example: { 'Component.svelte': '<script>...</script>', 'utils.js': 'export function ...' }. The playground accept multiple files so if are importing from other files just include them all at the root level.",
),
),
});
const playground_link_output_schema = v.object({
url: v.string(),
});
export async function playground_link_handler({
files,
name,
tailwind,
}: v.InferInput<typeof playground_link_schema>) {
const playground_base = new URL('https://svelte.dev/playground');
const playground_files: File[] = [];
let has_app_svelte = false;
for (const [filename, contents] of Object.entries(files)) {
if (filename === 'App.svelte') has_app_svelte = true;
playground_files.push({
type: 'file',
name: filename,
basename: filename.replace(/^.*[\\/]/, ''),
contents,
text: true,
});
}
if (!has_app_svelte) {
throw new Error('The files must contain an App.svelte file as the entry point');
}
const playground_config = {
name,
tailwind: tailwind ?? false,
files: playground_files,
};
playground_base.hash = await compress_and_encode_text(JSON.stringify(playground_config));
const url = playground_base.toString();
// use the embed path to have a cleaner UI for mcp-ui
playground_base.pathname = '/playground/embed';
return {
url,
iframe_url: playground_base.toString(),
};
}
// Create the UI resource for MCP Apps hosts (with adapter)
// This will be registered as a resource that MCP Apps hosts can fetch
const playground_ui_resource = createUIResource({
uri: 'ui://svelte/playground-link',
encoding: 'text',
resourceProps: {
_meta: {
ui: {
csp: {
connectDomains: ['https://svelte.dev'],
resourceDomains: ['https://svelte.dev'],
frameDomains: ['https://svelte.dev'],
baseUriDomains: ['https://svelte.dev'],
},
},
},
},
content: {
type: 'rawHtml',
// This is a placeholder HTML - the actual iframe URL will be set per-request
// MCP Apps hosts receive the tool input/output via postMessage
htmlString: `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
iframe { width: 100%; height: 100%; border: none; display: none; }
.loading { display: flex; align-items: center; justify-content: center; height: 100%; font-family: system-ui, sans-serif; color: #666; }
</style>
</head>
<body>
<div class="loading" id="loading">Loading playground...</div>
<iframe id="playground" allow="clipboard-write"></iframe>
<script>
function size_changed() {
const width = document.body.scrollWidth;
window.parent.postMessage({
jsonrpc: '2.0',
method: 'ui/notifications/size-changed',
params: {
width,
height: 800
}
}, '*');
}
// Signal that the widget is ready
window.parent.postMessage({ type: 'ui-lifecycle-iframe-ready' }, '*');
// Listen for render data from the adapter (for MCP Apps hosts)
window.addEventListener('message', (event) => {
if (event.data.type === 'ui-lifecycle-iframe-render-data') {
const renderData = event.data.payload.renderData || {};
const toolOutput = renderData.toolOutput;
// The tool output contains the iframe URL
if (toolOutput && toolOutput.structuredContent && toolOutput.structuredContent.url) {
const iframe = document.getElementById('playground');
const loading = document.getElementById('loading');
// Convert the URL to embed URL
const embedUrl = toolOutput.structuredContent.url.replace('/playground#', '/playground/embed#');
iframe.src = embedUrl;
iframe.style.display = 'block';
iframe.addEventListener("load", () => {
size_changed();
});
loading.style.display = 'none';
}
}
});
</script>
</body>
</html>`,
},
uiMetadata: {
'preferred-frame-size': ['100%', '1200px'],
},
adapters: {
mcpApps: { enabled: true },
},
});
export function playground_link(server: SvelteMcp) {
// Register the UI resource so MCP Apps hosts can fetch it
server.resource(
{
name: 'playground-link-ui',
description: 'UI resource for the Svelte Playground widget',
uri: playground_ui_resource.resource.uri,
icons,
},
() => {
return {
contents: [playground_ui_resource.resource],
};
},
);
server.tool(
{
name: 'playground-link',
description:
'Generates a Playground link given a Svelte code snippet. Once you have the final version of the code you want to send to the user, ALWAYS ask the user if it wants a playground link to allow it to quickly check the code in the playground before calling this tool. NEVER use this tool if you have written the component to a file in the user project. The playground accept multiple files so if are importing from other files just include them all at the root level.',
schema: playground_link_schema,
outputSchema: playground_link_output_schema,
annotations: {
title: 'Playground Link',
destructiveHint: false,
readOnlyHint: true,
openWorldHint: false,
},
icons,
// For MCP Apps hosts - points to the registered resource
_meta: {
ui: {
resourceUri: playground_ui_resource.resource.uri,
},
},
schema: v.object({
name: v.pipe(
v.string(),
v.description('The name of the Playground, it should reflect the user task'),
),
tailwind: v.pipe(
v.boolean(),
v.description(
"If the code requires Tailwind CSS to work...only send true if it it's using tailwind classes in the code",
),
),
files: v.pipe(
v.record(v.string(), v.string()),
v.description(
"An object where all the keys are the filenames (with extensions) and the values are the file content. For example: { 'Component.svelte': '<script>...</script>', 'utils.js': 'export function ...' }. The playground accept multiple files so if are importing from other files just include them all at the root level.",
),
),
}),
outputSchema: v.object({
url: v.string(),
}),
},
async ({ files, name, tailwind }) => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(server.ctx.sessionId, 'playground-link');
const playground_base = new URL('https://svelte.dev/playground');
const playground_files: File[] = [];
let has_app_svelte = false;
for (const [filename, contents] of Object.entries(files)) {
if (filename === 'App.svelte') has_app_svelte = true;
playground_files.push({
type: 'file',
name: filename,
basename: filename.replace(/^.*[\\/]/, ''),
contents,
text: true,
});
}
try {
const result = await playground_link_handler({ files, name, tailwind });
if (!has_app_svelte) {
return {
isError: true,
content: [
{
type: 'text',
text: JSON.stringify({ url: result.url }),
text: JSON.stringify({
error: 'The files must contain an App.svelte file as the entry point',
}),
},
// Embedded resource for MCP-UI hosts (no adapter, uses externalUrl)
createUIResource({
uri: 'ui://svelte/playground-link',
content: {
type: 'externalUrl',
iframeUrl: result.iframe_url,
},
uiMetadata: {
'preferred-frame-size': ['100%', '1200px'],
},
encoding: 'text',
}),
],
structuredContent: { url: result.url },
};
} catch (e) {
const error = e as Error;
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(
server.ctx.sessionId,
'playground-link-error',
error.message,
);
}
return tool.error(error.message);
}
const playground_config = {
name,
tailwind: tailwind ?? false,
files: playground_files,
};
playground_base.hash = await compress_and_encode_text(JSON.stringify(playground_config));
const content = {
url: playground_base.toString(),
};
return {
content: [
{
type: 'text',
text: JSON.stringify(content),
},
],
structuredContent: content,
};
},
);
}

View File

@@ -3,3 +3,80 @@ export const SECTIONS_LIST_INTRO =
export const SECTIONS_LIST_OUTRO =
"Carefully analyze the use_cases field for each section to identify which documentation is relevant for the user's specific query. The use_cases contain keywords for project types, features, components, and development stages. After identifying relevant sections, use the get-documentation tool with ALL relevant section titles or paths at once (can pass multiple sections as an array).";
export const USE_CASES_PROMPT = `You are tasked with analyzing Svelte 5 and SvelteKit documentation pages to identify when they would be useful.
Your task:
1. Read the documentation page content provided
2. Identify the main use cases, scenarios, or queries where this documentation would be relevant
3. Create a VERY SHORT, comma-separated list of use cases (maximum 200 characters total)
4. Think about what a developer might be trying to build or accomplish when they need this documentation
Guidelines:
- Focus on WHEN this documentation would be needed, not WHAT it contains
- Consider specific project types (e.g., "e-commerce site", "blog", "dashboard", "social media app")
- Consider specific features (e.g., "authentication", "forms", "data fetching", "animations")
- Consider specific components (e.g., "slider", "modal", "dropdown", "card")
- Consider development stages (e.g., "project setup", "deployment", "testing", "migration")
- Use "always" for fundamental concepts that apply to virtually all Svelte projects
- Be concise but specific
- Use lowercase
- Separate multiple use cases with commas
Examples of good use_cases:
- "always, any svelte project, core reactivity"
- "authentication, login systems, user management"
- "e-commerce, product listings, shopping carts"
- "forms, user input, data submission"
- "deployment, production builds, hosting setup"
- "animation, transitions, interactive ui"
- "routing, navigation, multi-page apps"
- "blog, content sites, markdown rendering"
Requirements:
- Maximum 200 characters (including spaces and commas)
- Lowercase only
- Comma-separated list of use cases
- Focus on WHEN/WHY someone would need this, not what it is
- Be specific about project types, features, or components when applicable
- Use "always" sparingly, only for truly universal concepts
- Do not include quotes or special formatting in your response
- Respond with ONLY the use cases text, no additional text
Here is the documentation page content to analyze:
`;
export const DISTILLED_PROMPT = `You are an expert in web development, specifically Svelte 5 and SvelteKit. Your task is to condense and distill a section of the Svelte documentation that will be provided inside the "<documentation>" tag below, into a concise format while preserving the most important information.
Shorten the text information AS MUCH AS POSSIBLE while covering key concepts.
Focus on:
1. Code examples with short explanations of how they work
2. Key concepts and APIs with their usage patterns
3. Important gotchas and best practices
4. Patterns that developers commonly use
Remove:
1. Redundant explanations
2. Verbose content that can be simplified
3. Marketing language
4. Legacy or deprecated content
5. Anything else that is not strictly necessary
Keep your output in markdown format. Preserve code blocks with their language annotations.
Maintain headings but feel free to combine or restructure sections to improve clarity.
Make sure all code examples use Svelte 5 runes syntax ($state, $derived, $effect, etc.)
Keep the following Svelte 5 syntax rules in mind whend distilling the documentation:
* There is no colon (:) in event modifiers. You MUST use "onclick" instead of "on:click".
* Runes do not need to be imported, they are globals.
* $state() runes are always declared using let, never with const.
* When passing a function to $derived, you must always use $derived.by(() => ...).
* Error boundaries can only catch errors during component rendering and at the top level of an $effect inside the error boundary.
* Error boundaries do not catch errors in onclick or other event handlers.
IMPORTANT: All code examples MUST come from the documentation verbatim, do NOT create new code examples. Do NOT modify existing code examples.
IMPORTANT: Because of changes in Svelte 5 syntax, do not include content from your existing knowledge, you may only use knowledge from the <documentation> tag below.
Here is the documentation you must condense:
`;

View File

@@ -1,149 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { InMemoryTransport } from '@tmcp/transport-in-memory';
import { beforeEach, describe, expect, it } from 'vitest';
import { server } from '../../index.js';
const transport = new InMemoryTransport(server);
let session: ReturnType<typeof transport.session>;
async function autofixer_tool_call(
code: string,
is_error = false,
desired_svelte_version = 5,
async = false,
) {
const result = await session.callTool('svelte-autofixer', {
code,
desired_svelte_version,
filename: 'App.svelte',
async,
});
expect(result).toBeDefined();
if (is_error) {
return result as any;
}
expect(result.structuredContent).toBeDefined();
return result.structuredContent as any;
}
describe('svelte-autofixer tool', () => {
beforeEach(async () => {
session = transport.session();
session = transport.session();
await session.initialize(
'2025-06-18',
{},
{
name: 'test-client',
version: '1.0.0',
},
);
});
it('should add suggestions for js parse errors', async () => {
const content = await autofixer_tool_call(`<script>
$state count = 0;
</script>`);
expect(content.issues.length).toBeGreaterThan(0);
expect(content.suggestions).toContain(
"The code can't be compiled because a Javascript parse error. In case you are using runes like this `$state variable_name = 3;` or `$derived variable_name = 3 * count` that's not how runes are used. You need to use them as function calls without importing them: `const variable_name = $state(3)` and `const variable_name = $derived(3 * count)`.",
);
});
it('should add suggestions for snippets declared in script tag', async () => {
const content = await autofixer_tool_call(`<script>
{#snippet my_snippet()}
some content
{/snippet}
</script>`);
expect(content.issues.length).toBeGreaterThan(0);
expect(content.suggestions).toContain(
"The code can't be compiled because a Javascript parse error. The error suggests you have a `{#snippet ...}` block inside the `<script>` tag. Snippets are template syntax and should be declared in the markup section of the component, not in the script. Move the snippet outside of the `<script>` tag. Snippets declared in the markup can also be accessed in the script tag in case you need them.",
);
});
it('should error out if async is true with a version less than 5', async () => {
const content = await autofixer_tool_call(
`<script>
$state count = 0;
</script>`,
true,
4,
true,
);
expect(content.isError).toBeTruthy();
expect(content.content[0]).toBeDefined();
expect(content.content[0].text).toBe(
'The async option can only be used with Svelte version 5 or higher.',
);
});
it('should not add suggestion/issues if async is true and await is used in the template/derived', async () => {
const content = await autofixer_tool_call(
`<script>
import { slow_double } from './utils.js';
let count = $state(0);
let double = $derived(await slow_double(count));
</script>
{double}
{await slow_double(count)}`,
false,
5,
true,
);
expect(content.issues).toHaveLength(0);
expect(content.suggestions).toHaveLength(0);
expect(content.require_another_tool_call_after_fixing).toBeFalsy();
});
it('should add suggestion/issues if async is false and await is used in the template/derived', async () => {
const content = await autofixer_tool_call(
`<script>
import { slow_double } from './utils.js';
let count = $state(0);
let double = $derived(await slow_double(count));
</script>
{double}
{await slow_double(count)}`,
false,
5,
);
expect(content.issues.length).toBeGreaterThanOrEqual(1);
expect(content.issues).toEqual(
expect.arrayContaining([expect.stringContaining('experimental_async')]),
);
expect(content.require_another_tool_call_after_fixing).toBeTruthy();
});
it('should add suggestions for css invalid identifier', async () => {
const content = await autofixer_tool_call(`<script>
let my_color = $state('red');
</script>
<style>
.my-class {
color: {my_color};
}
</style>`);
expect(content.issues.length).toBeGreaterThan(0);
expect(content.suggestions).toContain(
"The code can't be compiled because a valid CSS identifier is expected. This sometimes means you are trying to use a variable in CSS like this: `color: {my_color}` but Svelte doesn't support that. You can use inline CSS variables for that `<div style:--color={my_color}></div>` and then use the variable as usual in CSS with `color: var(--color)`.",
);
});
it('should error in case the passed in version is different from 4 or 5', async () => {
const content = await autofixer_tool_call(`whatever`, true, 3);
expect(content.content).toBeDefined();
expect(content.content[0]).toBeDefined();
expect(content.content[0].text).toContain(
'The desired_svelte_version MUST be either 4 or 5 but received "3"',
);
});
});

View File

@@ -4,104 +4,6 @@ import * as v from 'valibot';
import { add_compile_issues } from '../../autofixers/add-compile-issues.js';
import { add_eslint_issues } from '../../autofixers/add-eslint-issues.js';
import { add_autofixers_issues } from '../../autofixers/add-autofixers-issues.js';
import { icons } from '../../icons/index.js';
import { tool } from 'tmcp/utils';
const autofixer_schema = v.object({
code: v.string(),
desired_svelte_version: v.pipe(
v.union([v.string(), v.number()]),
v.description(
'The desired svelte version...if possible read this from the package.json of the user project, otherwise use some hint from the wording (if the user asks for runes it wants version 5). Default to 5 in case of doubt.',
),
),
async: v.pipe(
v.optional(v.boolean()),
v.description(
'If true the code is an async component/module and might use await in the markup or top-level awaits in the script tag. If possible check the svelte.config.js/svelte.config.ts to check if the option is enabled otherwise asks the user if they prefer using it or not. You can only use this option if the version is 5.',
),
),
filename: v.pipe(
v.optional(v.string()),
v.description(
'The filename of the component if available, it MUST be only the Component name with .svelte or .svelte.ts extension and not the entire path.',
),
),
});
const autofixer_output_schema = v.object({
issues: v.array(v.string()),
suggestions: v.array(v.string()),
require_another_tool_call_after_fixing: v.boolean(),
});
export async function svelte_autofixer_handler({
code,
desired_svelte_version: desired_svelte_version_unchecked,
async,
filename: filename_or_path,
}: v.InferInput<typeof autofixer_schema>) {
// we validate manually because some clients don't support union in the input schema (looking at you cursor)
const parsed_version = v.safeParse(
v.union([v.literal(4), v.literal(5), v.literal('4'), v.literal('5')]),
desired_svelte_version_unchecked,
);
if (parsed_version.success === false) {
throw new Error(
`The desired_svelte_version MUST be either 4 or 5 but received "${desired_svelte_version_unchecked}"`,
);
}
const desired_svelte_version = parsed_version.output;
if (async && +desired_svelte_version < 5) {
throw new Error('The async option can only be used with Svelte version 5 or higher.');
}
const content: {
issues: string[];
suggestions: string[];
require_another_tool_call_after_fixing: boolean;
} = { issues: [], suggestions: [], require_another_tool_call_after_fixing: false };
try {
// just in case the LLM sends a full path we extract the filename...it's not really needed
// but it's nice to have a filename in the errors
const filename = filename_or_path ? basename(filename_or_path) : 'Component.svelte';
add_compile_issues(content, code, +desired_svelte_version, filename, async);
add_autofixers_issues(content, code, +desired_svelte_version, filename, async);
await add_eslint_issues(content, code, +desired_svelte_version, filename, async);
} catch (e: unknown) {
const error = e as Error & { start?: { line: number; column: number }; frame?: string };
content.issues.push(
`${error.message} at line ${error.start?.line}, column ${error.start?.column}`,
);
if (error.message.includes('js_parse_error')) {
// Check if the error frame contains template syntax that was incorrectly placed in the script tag
if (error.frame?.includes('{#snippet')) {
content.suggestions.push(
"The code can't be compiled because a Javascript parse error. The error suggests you have a `{#snippet ...}` block inside the `<script>` tag. Snippets are template syntax and should be declared in the markup section of the component, not in the script. Move the snippet outside of the `<script>` tag. Snippets declared in the markup can also be accessed in the script tag in case you need them.",
);
} else {
content.suggestions.push(
"The code can't be compiled because a Javascript parse error. In case you are using runes like this `$state variable_name = 3;` or `$derived variable_name = 3 * count` that's not how runes are used. You need to use them as function calls without importing them: `const variable_name = $state(3)` and `const variable_name = $derived(3 * count)`.",
);
}
} else if (error.message.includes('css_expected_identifier')) {
content.suggestions.push(
"The code can't be compiled because a valid CSS identifier is expected. This sometimes means you are trying to use a variable in CSS like this: `color: {my_color}` but Svelte doesn't support that. You can use inline CSS variables for that `<div style:--color={my_color}></div>` and then use the variable as usual in CSS with `color: var(--color)`.",
);
}
}
if (content.issues.length > 0 || content.suggestions.length > 0) {
content.require_another_tool_call_after_fixing = true;
}
return content;
}
export function svelte_autofixer(server: SvelteMcp) {
server.tool(
@@ -110,44 +12,98 @@ export function svelte_autofixer(server: SvelteMcp) {
title: 'Svelte Autofixer',
description:
'Given a svelte component or module returns a list of suggestions to fix any issues it has. This tool MUST be used whenever the user is asking to write svelte code before sending the code back to the user',
schema: autofixer_schema,
outputSchema: autofixer_output_schema,
schema: v.object({
code: v.string(),
desired_svelte_version: v.pipe(
v.union([v.string(), v.number()]),
v.description(
'The desired svelte version...if possible read this from the package.json of the user project, otherwise use some hint from the wording (if the user asks for runes it wants version 5). Default to 5 in case of doubt.',
),
),
filename: v.pipe(
v.optional(v.string()),
v.description(
'The filename of the component if available, it MUST be only the Component name with .svelte or .svelte.ts extension and not the entire path.',
),
),
}),
outputSchema: v.object({
issues: v.array(v.string()),
suggestions: v.array(v.string()),
require_another_tool_call_after_fixing: v.boolean(),
}),
annotations: {
title: 'Svelte Autofixer',
destructiveHint: false,
readOnlyHint: true,
openWorldHint: false,
},
icons,
},
async ({
code,
filename: filename_or_path,
desired_svelte_version: desired_svelte_version_unchecked,
async,
}) => {
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-autofixer');
// we validate manually because some clients don't support union in the input schema (looking at you cursor)
const parsed_version = v.safeParse(
v.union([v.literal(4), v.literal(5), v.literal('4'), v.literal('5')]),
desired_svelte_version_unchecked,
);
if (parsed_version.success === false) {
return {
isError: true,
content: [
{
type: 'text',
text: `The desired_svelte_version MUST be either 4 or 5 but received "${desired_svelte_version_unchecked}"`,
},
],
};
}
const desired_svelte_version = parsed_version.output;
const content: {
issues: string[];
suggestions: string[];
require_another_tool_call_after_fixing: boolean;
} = { issues: [], suggestions: [], require_another_tool_call_after_fixing: false };
try {
const content = await svelte_autofixer_handler({
code,
desired_svelte_version: desired_svelte_version_unchecked,
async,
filename: filename_or_path,
});
return tool.structured(content);
} catch (e) {
const error = e as Error;
if (server.ctx.sessionId && server.ctx.custom?.track) {
await server.ctx.custom?.track?.(
server.ctx.sessionId,
'svelte-autofixer-error',
error.message,
// just in case the LLM sends a full path we extract the filename...it's not really needed
// but it's nice to have a filename in the errors
const filename = filename_or_path ? basename(filename_or_path) : 'Component.svelte';
add_compile_issues(content, code, +desired_svelte_version, filename);
add_autofixers_issues(content, code, +desired_svelte_version, filename);
await add_eslint_issues(content, code, +desired_svelte_version, filename);
} catch (e: unknown) {
const error = e as Error & { start?: { line: number; column: number } };
content.issues.push(
`${error.message} at line ${error.start?.line}, column ${error.start?.column}`,
);
if (error.message.includes('js_parse_error')) {
content.suggestions.push(
"The code can't be compiled because a Javascript parse error. In case you are using runes like this `$state variable_name = 3;` or `$derived variable_name = 3 * count` that's not how runes are used. You need to use them as function calls without importing them: `const variable_name = $state(3)` and `const variable_name = $derived(3 * count)`.",
);
}
return tool.error(error.message);
}
if (content.issues.length > 0 || content.suggestions.length > 0) {
content.require_another_tool_call_after_fixing = true;
}
return {
content: [
{
type: 'text',
text: JSON.stringify(content),
},
],
structuredContent: content,
};
},
);
}

View File

@@ -1,14 +0,0 @@
export const icons = [
{
src: 'https://mcp.svelte.dev/logo.svg',
mimeType: 'image/svg+xml',
},
{
src: 'https://mcp.svelte.dev/logo.png',
mimeType: 'image/png',
},
{
src: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAACvdJREFUeJztXQuQVMUVHT5GCYmSDwaVMhQWmpSRRIEkJqmdFVQCRuRjCiVq8MMGKKTYGESEREAFhI2iSGkCFURCJKASimgpSviVrApEPoKLIGEF0aAIAgLCwsk927NxmZ2duf36zesZnFN1qqCU926fO6/79u3b3bFYAQUUUEABBRRQQAF5DsRjp6Eo1lbYW1gqHCcsE05J/HmYsI+wg/y/Z/i2N+8hQjYQni3sJZwmXC/8SHhciHrI/7ZHuEk4WzhIeL6wse/25BVEsFbCB4UfpxFby0PCZcJOvtuV8xCR2gj/IjwagvCpyK+or3RRp/hua05BRGkqLBFWZkn42jwinCe82He7cwIixLeF5Rn69mxwr/BXvtvvDdL4ZsIJiV9klMIncwYjLN96RAZpcEMOiMJXhMc8i4+EDXPECV/3rU3WIY1kXz9ZWJUDwidzwUk7OEvjGgtvEu4MTbDOXwH6tAFuuhC44QLg6m8C8Qauz53tW6vQIY1qLZwJE48HF+fy04D+PwJmjgVWvQzs2Azsfh/Yswv4+ANg51Zg7TLg7w8CQ7sAXc4I2h39VtjAt27OSPzq+yKMydTgOPDW60BVFdTYtQN4aCDQ8RTb930qbOdbPyeA+Zii2HJn4W9rB6xcqBc9FXZsAe7savvuDcLTfetoDRotHC7c5SQ8+/eHB5suJgx8ug+YcgdQ3MjGjjt862kFMbi9cI3zr/7G7wIVq8IRvjaOH5Px434ZqBtqbdkuzP2oSIw8S/g4XCdU3ZoD86YARw6HL35tJ/BL0Nt1v29964UY10jYDSbBFVz4yxoDv+tsBtkocOgAMOhnWvsqhE19a10HYlQT4QiYiCG4+F1OB2aNBw4fjEb8GqxbrrWRE8af+tb7BIhBLYQrnIRnaFj2GxO/+wJDVJ29E31r/n+IMecKVzqJz0H2pVnS13/mLiKjm+2bhG8DBz6x+7dvrwY6naqxeTPisUa+ta8JMVc59fX81dsKVR8WzQZ6tzZfE3md/PnFJ/X//ugRoO/3dLbHY+f6Fb+4esB9IbD4HPTCGmT/swEo7VT/ux4t1T/rjwO0bejiT3yzOM7JlX3quGszYMYYYO9H7sIzemGep+c56d95RRNg02rdM5+frm3LAJ8OYFXBfmvxB/7EJMzCwNb1QL/2+ndrv4KNr2mfOcKP+MXViycvWwl/zbeAF2YAVUfdhf9kN/DIEPuE2ujrdc9/f5v2mQ/4cUBR7DLYrNXe8n3T1x8/7iY8nff6i8CtFwfL8Zd0AFa+BOzbnf49lRXaZ07w5YD56kbf+J1w4vr9e4CxfW0TZ6nZq6VJPdTniNWLtM+6L3rx47Fz5MWH1Q3lgogL+Kt/9lGgewt34ZNJZ47pA7xbceI7nxitfUZp9A4oit2jMo7xPfv8oGB3RWFG9Q7nV5+OjKCemggc3G/erV8nuC5a8YurQ89ylXFMpLn86v/xmMkJZVP4ZN5eBLyzzuZr+2G0DojHmkO7qBJ0xWrNUjNYRil88perG+D3iR5NonVAUewH0JSO8JP+7JCd8FxEf2KMmaT5Et+O8yMVP+GAa1TGPT7MTvwN5SYZ519UG/b24YABKuOWPK0Xf84koNOXggtxZVNgeDfgr+OApc+YnD7nHOtfkb8/K4PrBDOQc2UtPPHZDTf34YA7VQZufFUn/tY3TY4miAgMcaeOALasybxceazKVEHMnWQmhfr13/r4ZOTiJxzwB5WBzExqwF+tbeMp3sR+wSd3HJuemWy+nGDiH5bBt5UvBwxVGckkmQZ/Gm7XeKavtV9XJux8BxhwaRAHjPMifsIB/VVGsh/WYMFUXaMZGU0baSKlMMGvKN0aQl0yAmzl0wHdVIZqZ8AH9gK/+Eb6Z/VrF176OhWYD2JyT++Enj4dcBE084Cxv9YLwGKra1vWfUaPs8JLX2fCB5XmfToHLPXpgDOFH2Y08qqvfZ5X0aDyLTN3GCLdwZCOJlO5baN7+toGC/6sjY5YaHaBHwfEq3NButKTxXOiEy8s6Auzyrw4oNoJRbFRKiOZz8k3cOKmc8C/4WuTt7z4PGjWA/g587OOCuyu2G2x+2I3xu6M3Rq7Ny3YbbL7zOwA7sxv4cUBCScsVv1SOLBxgMs2OFBzwE41kHLGbFNVzQAic9sYiPjbTywv76r8VIGb2wK7tmdN++r09W2XpLeBoa525rxwprYb+qVPB7SEzY5GTnbCrvfkpIyTM236mpM+DfQFuoN8OmC8WvwaMt3MhFgYeHOFffpamyJnglD3zLt8iX8htIvyyWQCbPooU+EQBFwj5iJ6kGzm7DLdO5hI1D1zlC8HTA0kfg0pHlPCTA3ziziWYYcjU81MOTP13CvFjFlDprz5y9aAyb5c/QJkIsaZ8H+dHJD8RXDH49S7zWIKF1G4mLJW+uElc4HHhppB3H5L6efkYg9rPbXge3XPvj16BxTFrg9N/CgYpPp6cqn2+d19OGCud1E1rKm+tk1fc7EmU5W1ISvCo920zQMr5KUHMxrHkg6WdvgSv/+Pg6evy5/XvodrwmdG6wCzyz2zcT3ONpHEyB7RCh9G+npwsfZ9K1ikFrUDrlUZx7I+gnkVlvvpPungZNkiqx4Yorqkr+k8/Zd7b6TiJxxQqjKOu85rg7tguIiejfrOHi2AZfPMRmsXcDMfj7XRvfeodMctfThAl4Z+Y0nqRnLpj1UQXGJ0FZ5hKUPUoBO62uBchOcK6d8/J3LxEw54QGVgZUX6BtMR3CQRpP6TAzzXb7lJw3Wpkt0VQ1ROCu3s8HPOqNoB3N6jAftt21/99NHh7J6vqb7++VdtxV8obOjLAcNURm5Q1u0wOaZt+F1XA9uUxV6ZwPQ1T9iy7/p4nOX5XsRPOKBEZah22s8to5nKEhlBcQsqt6K6gsFA8OprTrzu4Zq4TwdcrjJ2YolelGm/r/85DGc/fM9deMK9+np+5HF/HQfEqxdhMhvL0wptzvZZPNfkbJiYu+LLZpfK8nnhCM+VuPtucJ2ZLxI28yp+wgE8lmBzRoN50IV2R3oNeE4EY3EesMGDNlzBAz948If7noM34LMUMRlizL0qw8ff4i5iUHDpc2TPMCZ+i4W5deGDGHQptGvBa5UFumGB4SkPeXLf2MfVPk46o93/pQHMcfIbVQ1hvx5G9KIBJ1TclemeheWxlN2RyzdrQLtJg2RE5JqnSQcO9jwxN/hmixqy3nMS8uFMUDGS6wJbVA3j+i8r1bJR4Vz+XFgb+9jXd/CtqxWgzYySHAzphDCiG4KHtvLwVh7i6ib8buHdyIUQ0xZi9KnCdVYNLmlvQk0XrPhn8MqIE/kvYWvfOjoBpj5oj1XDmVDjiScs/dAunrCfZ9WyvnQ8HXkXDe8Uy91BVguYI8sGI8jNRjxCnkfJM8/Do+V5ogrjdy6is4vhmi6PoucAy8QZj6h3E55H5D+V97/6VIA5nthNIKYguCLFzdQspHXZuF2X7wk7w1caOduAuQ/A3Qnhk6HlaOTjIGsLxKtvPpqF3Ll85zXhlSftrz4VYA7tfigHfvWcKH5xrp9KBsxe4h0exOcteOf5bn9OACZEfRrRXMb2rnAgcvE4eZ+AuZitI8yOwmwIz/CXdwZHf2xMvgHmhjzOPt2urDLk4vgjyKWFknyAREoMV9skuou/wVyuzJl0pouYuSWUt3Hw8mbems1jM/P/Pi/f4PXiMAW/TA2w5GVcokspS/y5NCF42y/UpZoFFFBAAQUUUEABJy3+B6BFBuObiHkkAAAAAElFTkSuQmCC',
mimeType: 'image/png',
},
];

View File

@@ -3,15 +3,12 @@ import { McpServer } from 'tmcp';
import { setup_prompts, setup_resources, setup_tools } from './handlers/index.js';
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
import type { Schema } from '@sveltejs/mcp-schema';
import { icons } from './icons/index.js';
export const server = new McpServer(
{
name: 'Svelte MCP',
version: '0.0.1',
description: 'The official Svelte MCP server implementation',
websiteUrl: 'https://mcp.svelte.dev',
icons,
},
{
adapter: new ValibotJsonSchemaAdapter(),
@@ -24,18 +21,10 @@ export const server = new McpServer(
instructions:
'This is the official Svelte MCP server. It MUST be used whenever svelte development is involved. It can provide official documentation, code examples and correct your code. After you correct the component call this tool again to confirm all the issues are fixed.',
},
).withContext<{
db: LibSQLDatabase<Schema>;
track?: (sessionId: string, event: string, extra?: string) => Promise<void>;
}>();
).withContext<{ db: LibSQLDatabase<Schema> }>();
export type SvelteMcp = typeof server;
setup_tools(server);
setup_resources(server);
setup_prompts(server);
server.on('initialize', async ({ clientInfo: client_info }) => {
if (!server.ctx.custom?.track || !server.ctx.sessionId) return;
server.ctx.custom.track(server.ctx.sessionId, 'initialize', client_info.name);
});

View File

@@ -1,6 +1,7 @@
import * as v from 'valibot';
import { documentation_sections_schema } from '../lib/schemas.js';
import summary_data from '../use_cases.json' with { type: 'json' };
import distilled_data from '../distilled.json' with { type: 'json' };
export async function fetch_with_timeout(
url: string,
@@ -18,6 +19,16 @@ export async function fetch_with_timeout(
}
const summaries = (summary_data.summaries || {}) as Record<string, string>;
const distilled_summaries = (distilled_data.summaries || {}) as Record<string, string>;
const full_data = (distilled_data.content || {}) as Record<string, string>;
export function get_distilled_content(slug: string): string | null {
return distilled_summaries[slug] ?? null;
}
export function get_cached_content(slug: string): string | null {
return full_data[slug] ?? null;
}
export async function get_sections() {
const sections = await fetch_with_timeout(

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
# devtools-json Add-on
Installs [`vite-plugin-devtools-json`](https://github.com/ChromeDevTools/vite-plugin-devtools-json/) - a Vite plugin that generates a Chromium DevTools settings file at `/.well-known/appspecific/com.chrome.devtools.json`. Enables [workspaces feature](https://developer.chrome.com/docs/devtools/workspaces) to edit source files directly in Chromium browsers.
> [!NOTE]
> Enables feature for all dev server users with Chromium browsers. Allows browser to read/write all files in directory. Chrome's AI Assistance may send data to Google.
## Alternatives
**Disable in browser:** Visit `chrome://flags` and disable "DevTools Project Settings" and "DevTools Automatic Workspace Folders".
**Handle request manually:** Create `.well-known/appspecific/com.chrome.devtools.json` file or add to `handle` hook:
```js
/// file: src/hooks.server.js
import { dev } from '$app/environment';
export function handle({ event, resolve }) {
if (dev && event.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json') {
return new Response(undefined, { status: 404 });
}
return resolve(event);
}
```
## Usage
```sh
npx sv add devtools-json
```
Adds `vite-plugin-devtools-json` to Vite config.

View File

@@ -0,0 +1,46 @@
# Drizzle ORM
TypeScript ORM with relational and SQL-like query APIs, serverless-ready.
## Setup
```sh
npx sv add drizzle
```
**Includes:**
- Database access in SvelteKit server files
- `.env` for credentials
- Lucia auth compatibility
- Optional Docker config for local database
## Options
### database
Choose database variant:
- `postgresql` — popular open source
- `mysql` — popular open source
- `sqlite` — file-based, no server needed
```sh
npx sv add drizzle=database:postgresql
```
### client
SQL client (depends on database):
- **postgresql**: `postgres.js`, `neon`
- **mysql**: `mysql2`, `planetscale`
- **sqlite**: `better-sqlite3`, `libsql`, `turso`
```sh
npx sv add drizzle=database:postgresql+client:postgres.js
```
*Note: Can swap for [other Drizzle-compatible drivers](https://orm.drizzle.team/docs/connect-overview#next-steps) after setup*
### docker
Add Docker Compose config (postgresql/mysql only):
```sh
npx sv add drizzle=database:postgresql+client:postgres.js+docker:yes
```

View File

@@ -0,0 +1,15 @@
# ESLint
Lints and fixes code problems.
## Setup
```sh
npx sv add eslint
```
Installs:
- `eslint-plugin-svelte`
- `eslint.config.js`
- Updated `.vscode/settings.json`
- Auto-configured for TypeScript and Prettier if present

View File

@@ -0,0 +1,20 @@
# sv CLI
## Running sv CLI
```bash
npm: npx sv create
pnpm: pnpx sv create / pnpm dlx sv create
bun: bunx sv create
deno: deno run npm:sv create
yarn: yarn dlx sv create
```
## Troubleshooting
If `npx sv` doesn't work, package managers may prioritize local tools over registry packages. Common issues:
- Command does nothing
- Name collision with `runit`
- Windows PowerShell conflict with `Set-Variable`
See: [GitHub issues #472](https://github.com/sveltejs/cli/issues/472), [#259](https://github.com/sveltejs/cli/issues/259), [#317](https://github.com/sveltejs/cli/issues/317)

View File

@@ -0,0 +1,18 @@
# Lucia Auth
Auth setup following [Lucia auth guide](https://lucia-auth.com/).
## Usage
```sh
npx sv add lucia
```
Adds auth setup for SvelteKit + Drizzle following Lucia best practices.
## Options
**demo** - Include demo registration/login pages:
```sh
npx sv add lucia=demo:yes
```

View File

@@ -0,0 +1,11 @@
# mdsvex
[mdsvex](https://mdsvex.pngwn.io) is a markdown preprocessor for Svelte - allows using Svelte components in markdown and vice versa.
## Installation
```sh
npx sv add mdsvex
```
Installs and configures mdsvex in `svelte.config.js`.

View File

@@ -0,0 +1,13 @@
# CLI (`sv`)
Toolkit for creating and maintaining Svelte applications.
## Usage
Run with `npx` (or `pnpx` for pnpm):
```sh
npx sv <command> <args>
```
Uses local installation if available, otherwise downloads latest version without installing.

View File

@@ -0,0 +1,30 @@
# Paraglide i18n
Compiler-based i18n library with tree-shakable messages, small bundles, type-safety.
## Installation
```sh
npx sv add paraglide
```
## Includes
- Inlang project settings
- Paraglide Vite plugin
- SvelteKit `reroute` and `handle` hooks
- `text-direction` and `lang` attributes in `app.html`
- Updated `.gitignore`
- Optional demo page
## Options
**languageTags** - IETF BCP 47 language tags:
```sh
npx sv add paraglide="languageTags:en,es"
```
**demo** - Generate demo page:
```sh
npx sv add paraglide="demo:yes"
```

View File

@@ -0,0 +1,15 @@
# Playwright
Browser testing with [Playwright](https://playwright.dev).
## Usage
```sh
npx sv add playwright
```
Adds:
- Test scripts to `package.json`
- Playwright config file
- Updated `.gitignore`
- Demo test

View File

@@ -0,0 +1,15 @@
# Prettier
Opinionated code formatter for Svelte projects.
## Usage
```sh
npx sv add prettier
```
## Adds
- `package.json` scripts
- `.prettierignore` and `.prettierrc` config files
- ESLint config updates (if ESLint installed)

View File

@@ -0,0 +1,15 @@
# Storybook
Component workshop for Svelte/SvelteKit.
## Installation
```sh
npx sv add storybook
```
## Features
- Runs `npx storybook init` automatically
- Configures either [Storybook for SvelteKit](https://storybook.js.org/docs/get-started/frameworks/sveltekit) or [Storybook for Svelte & Vite](https://storybook.js.org/docs/get-started/frameworks/svelte-vite)
- Includes SvelteKit module mocking and automatic link handling

View File

@@ -0,0 +1,37 @@
# sv add
Adds functionality to existing Svelte projects.
## Usage
```sh
npx sv add
```
```sh
npx sv add [add-ons]
```
Select multiple space-separated add-ons or use interactive prompt.
## Options
- `-C`, `--cwd` — path to project root
- `--no-git-check` — skip dirty files prompt
- `--install` — install dependencies with specified package manager
- `--no-install` — skip dependency installation
## Official add-ons
- `devtools-json`
- `drizzle`
- `eslint`
- `lucia`
- `mdsvex`
- `paraglide`
- `playwright`
- `prettier`
- `storybook`
- `sveltekit-adapter`
- `tailwindcss`
- `vitest`

View File

@@ -0,0 +1,109 @@
# sv check
Finds errors and warnings in your project: unused CSS, accessibility hints, JS/TS compiler errors.
Requires Node 16+.
## Installation
```sh
npm i -D svelte-check
```
## Usage
```sh
npx sv check
```
## Options
### `--workspace <path>`
Path to workspace. Checks all subdirectories except `node_modules` and ignored paths.
### `--output <format>`
Display format: `human`, `human-verbose`, `machine`, `machine-verbose`
### `--watch`
Watch mode for changes.
### `--preserveWatchOutput`
Don't clear screen in watch mode.
### `--tsconfig <path>`
Path to `tsconfig`/`jsconfig`. Only files matched by config's `files`/`include`/`exclude` are checked. Reports errors from TS/JS files. If not provided, searches upward from project directory.
### `--no-tsconfig`
Only check Svelte files, ignore `.js`/`.ts` files.
### `--ignore <paths>`
Comma-separated quoted paths relative to workspace root:
```sh
npx sv check --ignore "dist,build"
```
Only effective with `--no-tsconfig` for diagnostics. With `--tsconfig`, only affects watched files.
### `--fail-on-warnings`
Exit with error code on warnings.
### `--compiler-warnings <warnings>`
Comma-separated `code:behaviour` pairs (`ignore` or `error`):
```sh
npx sv check --compiler-warnings "css_unused_selector:ignore,a11y_missing_attribute:error"
```
### `--diagnostic-sources <sources>`
Comma-separated sources (default: all active):
- `js` (includes TypeScript)
- `svelte`
- `css`
```sh
npx sv check --diagnostic-sources "js,svelte"
```
### `--threshold <level>`
Filter diagnostics:
- `warning` (default) — errors and warnings
- `error` — only errors
## Machine-readable output
`--output machine` or `machine-verbose` formats output for CI/automation.
Each row: columns separated by single space. First column: timestamp (ms). Second column: row type.
**START row:** workspace folder (quoted)
```
1590680325583 START "/home/user/language-tools/packages/language-server/test/plugins/typescript/testfiles"
```
**machine format:** filename, line, column, message (quoted)
```
1590680326283 ERROR "codeactions.svelte" 1:16 "Cannot find module 'blubb' or its corresponding type declarations."
1590680326778 WARNING "imported-file.svelte" 0:37 "Component has unused export property 'prop'. If it is for external reference only, please consider using `export const prop`"
```
**machine-verbose format:** ndjson with timestamp prefix
```
1590680326283 {"type":"ERROR","fn":"codeaction.svelte","start":{"line":1,"character":16},"end":{"line":1,"character":23},"message":"Cannot find module 'blubb' or its corresponding type declarations.","code":2307,"source":"js"}
1590680326778 {"type":"WARNING","filename":"imported-file.svelte","start":{"line":0,"character":37},"end":{"line":0,"character":51},"message":"Component has unused export property 'prop'. If it is for external reference only, please consider using `export const prop`","code":"unused-export-let","source":"svelte"}
```
**COMPLETED row:** summary
```
1590680326807 COMPLETED 20 FILES 21 ERRORS 1 WARNINGS 3 FILES_WITH_PROBLEMS
```
**FAILURE row:** runtime errors
```
1590680328921 FAILURE "Connection closed"
```
## FAQ
**Why no option to check only specific files?**
`svelte-check` needs the whole project for valid checks. Partial checks miss errors in unchanged files (e.g., renamed prop not updated at usage sites).

View File

@@ -0,0 +1,39 @@
# sv create
Sets up a new SvelteKit project with optional additional functionality.
## Usage
```sh
npx sv create [options] [path]
```
## Options
### `--from-playground <url>`
Create project from a [playground](/playground) URL. Downloads files, detects dependencies, and sets up complete project structure.
```sh
npx sv create --from-playground="https://svelte.dev/playground/hello-world"
```
### `--template <name>`
- `minimal` — barebones scaffolding
- `demo` — showcase app with word guessing game (works without JS)
- `library` — Svelte library template with `svelte-package`
### `--types <option>`
- `ts``.ts` files and `lang="ts"` in `.svelte` components
- `jsdoc` — [JSDoc syntax](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html) for types
### `--no-types`
Disable typechecking (not recommended)
### `--no-add-ons`
Skip interactive add-ons prompt
### `--install <package-manager>`
Install dependencies with: `npm`, `pnpm`, `yarn`, `bun`, or `deno`
### `--no-install`
Skip dependency installation

View File

@@ -0,0 +1,39 @@
# sv migrate
CLI tool for migrating Svelte(Kit) codebases. Delegates to [`svelte-migrate`](https://www.npmjs.com/package/svelte-migrate).
May add `@migration` task annotations in code for manual completion.
## Usage
```sh
npx sv migrate
```
Or specify migration:
```sh
npx sv migrate [migration]
```
## Migrations
### `app-state`
Migrates `$app/stores``$app/state` in `.svelte` files. [Details](/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated)
### `svelte-5`
Upgrades Svelte 4 → 5, converts components to [runes](../svelte/what-are-runes) syntax. [Migration guide](../svelte/v5-migration-guide)
### `self-closing-tags`
Replaces self-closing non-void elements. [PR](https://github.com/sveltejs/kit/pull/12128)
### `svelte-4`
Upgrades Svelte 3 → 4. [Migration guide](../svelte/v4-migration-guide)
### `sveltekit-2`
Upgrades SvelteKit 1 → 2. [Migration guide](../kit/migrating-to-sveltekit-2)
### `package`
Upgrades `@sveltejs/package` v1 → v2. [PR](https://github.com/sveltejs/kit/pull/8922)
### `routes`
Upgrades pre-release SvelteKit to v1 filesystem routing. [Discussion](https://github.com/sveltejs/kit/discussions/5774)

View File

@@ -0,0 +1,24 @@
# SvelteKit Adapters
Adapters enable deployment to various platforms.
## Usage
```sh
npx sv add sveltekit-adapter
```
Installs and configures chosen adapter in `svelte.config.js`.
## Adapter Options
- `auto` — [`@sveltejs/adapter-auto`](/docs/kit/adapter-auto) - auto-selects adapter, less configurable
- `node` — [`@sveltejs/adapter-node`](/docs/kit/adapter-node) - standalone Node server
- `static` — [`@sveltejs/adapter-static`](/docs/kit/adapter-static) - static site generator (SSG)
- `vercel` — [`@sveltejs/adapter-vercel`](/docs/kit/adapter-vercel) - Vercel deployment
- `cloudflare` — [`@sveltejs/adapter-cloudflare`](/docs/kit/adapter-cloudflare) - Cloudflare deployment
- `netlify` — [`@sveltejs/adapter-netlify`](/docs/kit/adapter-netlify) - Netlify deployment
```sh
npx sv add sveltekit-adapter=adapter:node
```

View File

@@ -0,0 +1,26 @@
# Tailwind CSS
## Setup
```sh
npx sv add tailwindcss
```
## What's Installed
- Tailwind config following SvelteKit guide
- Tailwind Vite plugin
- Updated `app.css` and `+layout.svelte` (SvelteKit) or `App.svelte` (Vite)
- Prettier integration (if installed)
## Options
Add plugins via CLI:
```sh
npx sv add tailwindcss="plugins:typography"
```
Available plugins:
- `typography` — [@tailwindcss/typography](https://github.com/tailwindlabs/tailwindcss-typography)
- `forms` — [@tailwindcss/forms](https://github.com/tailwindlabs/tailwindcss-forms)

View File

@@ -0,0 +1,11 @@
# Vitest
Vite-native testing framework for SvelteKit.
## Setup
```sh
npx sv add vitest
```
Installs packages, adds scripts to `package.json`, configures client/server-aware Svelte testing in Vite config, and includes demo tests.

View File

@@ -0,0 +1,33 @@
# $app/environment
```js
import { browser, building, dev, version } from '$app/environment';
```
## browser
`true` if app is running in the browser.
```dts
const browser: boolean;
```
## building
`true` during the build step and prerendering.
```dts
const building: boolean;
```
## dev
Whether dev server is running. Not guaranteed to match `NODE_ENV` or `MODE`.
```dts
const dev: boolean;
```
## version
The value of `config.kit.version.name`.
```dts
const version: string;
```

View File

@@ -0,0 +1,75 @@
# $app/forms
```js
import { applyAction, deserialize, enhance } from '$app/forms';
```
## applyAction
Updates `form` property and `page.status` of current page with given data. Redirects to nearest error page on error.
```dts
function applyAction<
Success extends Record<string, unknown> | undefined,
Failure extends Record<string, unknown> | undefined
>(
result: import('@sveltejs/kit').ActionResult<Success, Failure>
): Promise<void>;
```
## deserialize
Deserializes form submission response.
```js
// @errors: 7031
import { deserialize } from '$app/forms';
async function handleSubmit(event) {
const response = await fetch('/form?/action', {
method: 'POST',
body: new FormData(event.target)
});
const result = deserialize(await response.text());
// ...
}
```
```dts
function deserialize<
Success extends Record<string, unknown> | undefined,
Failure extends Record<string, unknown> | undefined
>(
result: string
): import('@sveltejs/kit').ActionResult<Success, Failure>;
```
## enhance
Progressive enhancement for `<form>` elements.
**`submit` function**: Called on submission with FormData and `action`. Call `cancel` to prevent submission. Use abort `controller` to cancel if another submission starts. Return a function to handle server response, or return nothing for default behavior.
**Default behavior**:
- Updates `form` prop if action is on same page
- Updates `page.status`
- Resets form and invalidates all data on successful submission (no redirect)
- Redirects on redirect response
- Redirects to error page on unexpected error
**Custom callback**: Call `update` for default behavior with options:
- `reset: false` - don't reset form values after success
- `invalidateAll: false` - don't call `invalidateAll` after submission
```dts
function enhance<
Success extends Record<string, unknown> | undefined,
Failure extends Record<string, unknown> | undefined
>(
form_element: HTMLFormElement,
submit?: import('@sveltejs/kit').SubmitFunction<Success, Failure>
): {
destroy(): void;
};
```

View File

@@ -0,0 +1,160 @@
# $app/navigation
```js
import {
afterNavigate,
beforeNavigate,
disableScrollHandling,
goto,
invalidate,
invalidateAll,
onNavigate,
preloadCode,
preloadData,
pushState,
refreshAll,
replaceState
} from '$app/navigation';
```
## afterNavigate
Runs callback when component mounts and on every navigation. Must be called during component initialization. Active while component is mounted.
```dts
function afterNavigate(
callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void
): void;
```
## beforeNavigate
Intercepts navigation before it happens (links, `goto()`, browser back/forward). Call `cancel()` to prevent navigation. For `'leave'` navigations (closing tab/navigating away), `cancel()` triggers native browser confirmation dialog.
- `navigation.to.route.id` is `null` for non-SvelteKit routes
- `navigation.willUnload` is `true` for `'leave'` navigations and `'link'` navigations where `navigation.to.route === null`
Must be called during component initialization. Active while component is mounted.
```dts
function beforeNavigate(
callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void
): void;
```
## disableScrollHandling
Disables SvelteKit's built-in scroll handling when called during page update (in `onMount`, `afterNavigate`, or actions). Discouraged as it breaks user expectations.
```dts
function disableScrollHandling(): void;
```
## goto
Navigate programmatically. Returns Promise that resolves on navigation completion. For external URLs, use `window.location = url` instead.
```dts
function goto(
url: string | URL,
opts?: {
replaceState?: boolean | undefined;
noScroll?: boolean | undefined;
keepFocus?: boolean | undefined;
invalidateAll?: boolean | undefined;
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
state?: App.PageState | undefined;
}
): Promise<void>;
```
## invalidate
Re-runs `load` functions that depend on the URL (via `fetch` or `depends`). Returns Promise that resolves when page updates.
- String/URL must match exactly what was passed to `fetch`/`depends` (including query params)
- Custom identifiers: use format `[a-z]+:` (e.g. `custom:state`)
- Function predicate receives full URL, re-runs if returns `true`
```ts
// Match '/path' regardless of query parameters
import { invalidate } from '$app/navigation';
invalidate((url) => url.pathname === '/path');
```
```dts
function invalidate(
resource: string | URL | ((url: URL) => boolean)
): Promise<void>;
```
## invalidateAll
Re-runs all `load` functions for current page. Returns Promise that resolves when page updates.
```dts
function invalidateAll(): Promise<void>;
```
## onNavigate
Runs callback immediately before navigation (except full-page navigations). Return Promise to delay navigation completion (useful for `document.startViewTransition`). Avoid slow promises as navigation appears stalled.
Returning a function (or Promise resolving to function) calls it after DOM updates.
Must be called during component initialization. Active while component is mounted.
```dts
function onNavigate(
callback: (navigation: import('@sveltejs/kit').OnNavigate) =>
MaybePromise<(() => void) | void>
): void;
```
## preloadCode
Imports code for routes not yet fetched. Specify routes by pathname: `/about` or `/blog/*`. Doesn't call `load` functions. Returns Promise resolving when modules imported.
```dts
function preloadCode(pathname: string): Promise<void>;
```
## preloadData
Preloads page: imports code and calls `load` functions. Same as hovering/tapping `<a>` with `data-sveltekit-preload-data`. Makes navigation instantaneous if next navigation is to `href`. Returns Promise with `load` results.
```dts
function preloadData(href: string): Promise<
| { type: 'loaded'; status: number; data: Record<string, any>; }
| { type: 'redirect'; location: string; }
>;
```
## pushState
Creates new history entry with given `page.state`. Pass `''` for current URL. Used for shallow routing.
```dts
function pushState(url: string | URL, state: App.PageState): void;
```
## refreshAll
Refreshes all active remote functions and re-runs `load` functions (unless disabled). Returns Promise resolving when page updates.
```dts
function refreshAll({
includeLoadFunctions
}?: {
includeLoadFunctions?: boolean;
}): Promise<void>;
```
## replaceState
Replaces current history entry with given `page.state`. Pass `''` for current URL. Used for shallow routing.
```dts
function replaceState(url: string | URL, state: App.PageState): void;
```

View File

@@ -0,0 +1,54 @@
# $app/paths
```js
import { asset, assets, base, resolve, resolveRoute } from '$app/paths';
```
## asset
Resolve URL of an asset in `static` directory by prefixing with `config.kit.paths.assets` or base path.
During SSR, base path is relative and depends on current page.
```svelte
<script>
import { asset } from '$app/paths';
</script>
<img alt="a potato" src={asset('/potato.jpg')} />
```
```dts
function asset(file: Asset): string;
```
## resolve
Resolve pathname by prefixing with base path, or resolve route ID by populating dynamic segments with parameters.
During SSR, base path is relative and depends on current page.
```js
// @errors: 7031
import { resolve } from '$app/paths';
// using a pathname
const resolved = resolve(`/blog/hello-world`);
// using a route ID plus parameters
const resolved = resolve('/blog/[slug]', {
slug: 'hello-world'
});
```
```dts
function resolve<T extends RouteId | Pathname>(
...args: ResolveArgs<T>
): ResolvedPathname;
```
## Deprecated
- **assets**: Use `asset(...)` instead. Absolute path matching `config.kit.paths.assets`.
- **base**: Use `resolve(...)` instead. String matching `config.kit.paths.base`.
- **resolveRoute**: Use `resolve(...)` instead.

Some files were not shown because too many files have changed in this diff Show More