mirror of
https://github.com/sveltejs/ai-tools.git
synced 2026-07-14 02:21:58 +08:00
Compare commits
219 Commits
@sveltejs/
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35b6a5a51c | ||
|
|
8a7763868a | ||
|
|
7239d7cb13 | ||
|
|
ff78a85ddf | ||
|
|
8984bb0303 | ||
|
|
3fa951f1b6 | ||
|
|
a668188dfa | ||
|
|
59dcbff136 | ||
|
|
129a307df0 | ||
|
|
d051d7ce6c | ||
|
|
54a84c5512 | ||
|
|
2e8f79038e | ||
|
|
1b6b7589b5 | ||
|
|
fea691996f | ||
|
|
802b379f7a | ||
|
|
fc391d0128 | ||
|
|
575dcc7d2b | ||
|
|
88cea9e539 | ||
|
|
fdb1bc7370 | ||
|
|
5b4d3aa68a | ||
|
|
04c52f2b72 | ||
|
|
0ea2a617ef | ||
|
|
484453e5f8 | ||
|
|
841af5b3a4 | ||
|
|
1ce957ac72 | ||
|
|
e429cd7839 | ||
|
|
2ded13539a | ||
|
|
96c50acae2 | ||
|
|
4920088e5c | ||
|
|
8557f0af6f | ||
|
|
972d0f0bb2 | ||
|
|
7bf364a9d5 | ||
|
|
d06d758b81 | ||
|
|
e5ce7437c4 | ||
|
|
2f422ee190 | ||
|
|
14f087cd7a | ||
|
|
1ef5ddf605 | ||
|
|
0e55ee792d | ||
|
|
84ec24b6f6 | ||
|
|
710cebe539 | ||
|
|
b2a380c4ce | ||
|
|
eef0a9b4d9 | ||
|
|
260b36e8af | ||
|
|
6df3ebe568 | ||
|
|
27a2fc5653 | ||
|
|
5cd99d8234 | ||
|
|
e9f19199cb | ||
|
|
480b46df0a | ||
|
|
5f5fb27977 | ||
|
|
29cfa77c39 | ||
|
|
249923b1e5 | ||
|
|
8c67cae90f | ||
|
|
4aad2e0cfe | ||
|
|
02935b00a6 | ||
|
|
1ea98adacd | ||
|
|
494409cc42 | ||
|
|
46d8f6cce8 | ||
|
|
8dc63dca08 | ||
|
|
19fedcd35f | ||
|
|
b4eb5cc960 | ||
|
|
6676fd8116 | ||
|
|
a755a33a5f | ||
|
|
556f96cfaf | ||
|
|
77a3340c2f | ||
|
|
9ac8fd51e7 | ||
|
|
c764308d79 | ||
|
|
01a7e6a8d3 | ||
|
|
d8ed686e3a | ||
|
|
6f0390d0a9 | ||
|
|
c2c1b3e5e7 | ||
|
|
cdfbb907b6 | ||
|
|
2eb2b18008 | ||
|
|
e8554f3d8f | ||
|
|
0213bd951f | ||
|
|
2245cb2dc9 | ||
|
|
2a5f7d6314 | ||
|
|
8518e627d3 | ||
|
|
9e824da9e2 | ||
|
|
b38f2c11da | ||
|
|
ea37c7120c | ||
|
|
099e939f79 | ||
|
|
69b36eefdc | ||
|
|
15ad554f53 | ||
|
|
74477448ce | ||
|
|
6f538265d1 | ||
|
|
71295bc11f | ||
|
|
b5040ff5cf | ||
|
|
45c961417f | ||
|
|
57e2d1def1 | ||
|
|
398a703580 | ||
|
|
75c802a115 | ||
|
|
53a634cdb0 | ||
|
|
bcdc33e7a5 | ||
|
|
825ae33427 | ||
|
|
ccf940cc45 | ||
|
|
b2f195fb7b | ||
|
|
d8e4b18bff | ||
|
|
6a2198b433 | ||
|
|
2ce60c6110 | ||
|
|
0f8987fdcf | ||
|
|
42911e2631 | ||
|
|
655eb85eba | ||
|
|
89403a7d0c | ||
|
|
3747623d55 | ||
|
|
c1f230455f | ||
|
|
9dfb4dedb4 | ||
|
|
b891e4860b | ||
|
|
c9e8508dd9 | ||
|
|
9896406aff | ||
|
|
b01ae9069b | ||
|
|
b6db495242 | ||
|
|
3926310107 | ||
|
|
848627549f | ||
|
|
283164ca7e | ||
|
|
c6ee414f62 | ||
|
|
ea5bdf66dc | ||
|
|
7d707202d1 | ||
|
|
f0daadfbd0 | ||
|
|
15a7774da7 | ||
|
|
98efa1e09e | ||
|
|
e20cf2974d | ||
|
|
b2ee968a3f | ||
|
|
60297b3c49 | ||
|
|
39076da8ce | ||
|
|
fba733646a | ||
|
|
7fcd4705a5 | ||
|
|
af7d341ba5 | ||
|
|
52546551ff | ||
|
|
1f0a5f1519 | ||
|
|
0bf04bad2e | ||
|
|
f001918925 | ||
|
|
67487c324a | ||
|
|
5beeef5543 | ||
|
|
e1a03fdb85 | ||
|
|
384c1fd209 | ||
|
|
b3027fd815 | ||
|
|
849bf2ad49 | ||
|
|
314538c8e7 | ||
|
|
a9994310c0 | ||
|
|
9fb1a403b7 | ||
|
|
3c7b5033a4 | ||
|
|
b911a00bb7 | ||
|
|
f6ce89ff34 | ||
|
|
846514858e | ||
|
|
b69ea052bd | ||
|
|
e56159dda6 | ||
|
|
1e83c35faa | ||
|
|
31edfe1b5f | ||
|
|
3fabcc0f9b | ||
|
|
deb5f2670c | ||
|
|
02c951baa8 | ||
|
|
41ceb83838 | ||
|
|
3c3a26f031 | ||
|
|
6589c7e250 | ||
|
|
e09b8cd0b9 | ||
|
|
7f52a2b1be | ||
|
|
4eecd75759 | ||
|
|
9015753f77 | ||
|
|
4d6a9cb333 | ||
|
|
60aa30397f | ||
|
|
17ed3a3e23 | ||
|
|
f49bd06fbd | ||
|
|
b98c042ae3 | ||
|
|
917a93d3fd | ||
|
|
371e96befc | ||
|
|
bdfd5a109f | ||
|
|
1c6c0a9fa7 | ||
|
|
a321244543 | ||
|
|
ed25933466 | ||
|
|
72f91dfb7b | ||
|
|
d36855c447 | ||
|
|
5fa2baa270 | ||
|
|
6543150a5b | ||
|
|
4c7f7feeba | ||
|
|
579be877fa | ||
|
|
0d55c0f61a | ||
|
|
7d7b08610d | ||
|
|
c08d8d4df7 | ||
|
|
12dd3c16ac | ||
|
|
ca17a18677 | ||
|
|
cf62286912 | ||
|
|
a4dfaab1c6 | ||
|
|
7b396ad63f | ||
|
|
a9653f9c74 | ||
|
|
cabf1fd96a | ||
|
|
2d50ffd38c | ||
|
|
66c9056e0f | ||
|
|
e639e3ad5c | ||
|
|
322f416c3d | ||
|
|
c40a3fcb5c | ||
|
|
a282623cc7 | ||
|
|
8f6abc6192 | ||
|
|
d0bed3e8f0 | ||
|
|
4c98732f5f | ||
|
|
1f88817cf0 | ||
|
|
87af64f4bc | ||
|
|
c1678b2f36 | ||
|
|
a8af3c72ca | ||
|
|
534a72cae7 | ||
|
|
3b301d7d9c | ||
|
|
33a0e17ee1 | ||
|
|
bf5f31c867 | ||
|
|
62abaacbd3 | ||
|
|
87fab2d884 | ||
|
|
9cf50c9b62 | ||
|
|
9a43aaf100 | ||
|
|
c0477385b8 | ||
|
|
db283da593 | ||
|
|
7d7547f6e2 | ||
|
|
0360d00955 | ||
|
|
65d403af1e | ||
|
|
d794d6bec3 | ||
|
|
ec9c5b3415 | ||
|
|
b508a4ea49 | ||
|
|
044f0988b9 | ||
|
|
c5c6ba6580 | ||
|
|
fb2240d60c | ||
|
|
469b2071e7 | ||
|
|
fc39b44859 |
195
.agents/skills/writing-great-skills/GLOSSARY.md
Normal file
195
.agents/skills/writing-great-skills/GLOSSARY.md
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
# Glossary — Building Great Skills
|
||||||
|
|
||||||
|
The domain model for what makes a skill great. A skill exists to wrangle determinism out of a stochastic system; the root virtue is **Predictability**, and every term below is a lever on it. This is the disclosed reference for [`writing-great-skills`](SKILL.md).
|
||||||
|
|
||||||
|
The terms are grouped by axis: **Invocation** (how a skill is reached), **Information Hierarchy** (how its content is arranged), **Steering** (how the agent's runtime behaviour is shaped), and **Pruning** (how it is kept lean). Each **failure mode** lives beside the lever that cures it, tagged _failure mode_.
|
||||||
|
|
||||||
|
**Bold terms** in any definition are themselves defined in this glossary; find them by their heading.
|
||||||
|
|
||||||
|
## Predictability
|
||||||
|
|
||||||
|
The degree to which a skill makes the agent behave the same _way_ on every run — the same process, not the same output (a brainstorming skill should _predictably_ diverge; its tokens vary, its behaviour doesn't). The root virtue every other term serves — cost and maintainability are symptoms of it, not rivals.
|
||||||
|
|
||||||
|
_Avoid_: consistency, reliability, robustness, output-determinism
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
How a skill is reached — and the two loads you pay for the choice.
|
||||||
|
|
||||||
|
### Model-Invoked
|
||||||
|
|
||||||
|
A skill that keeps its **description** field, so the agent can see it and fire it autonomously — and the human can still type its name, so model-invocation always _includes_ user reach. There is no model-only state: a description only ever _adds_ agent discovery, never removes the human's. Pays a permanent **context load** on every turn in exchange for that discoverability. Reachable by other skills, because the description that makes it agent-discoverable makes it invocable. A model-invoked skill whose content is all **reference** is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Pick model-invocation only when the agent must reach the skill on its own; if it never fires except by hand, drop the description and pay no context load.
|
||||||
|
|
||||||
|
_Avoid_: ability, tool, capability
|
||||||
|
|
||||||
|
### User-Invoked
|
||||||
|
|
||||||
|
A skill with its **description** stripped — invisible to the agent and reachable only by the human typing its name (user-_only_, where **model-invoked** is user-_and-agent_). Trades agent-discoverability for zero **context load**. Because it has no description, nothing but the human can reach it: no other skill can fire it.
|
||||||
|
|
||||||
|
_Avoid_: procedure, workflow, command
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
The skill's machine-readable trigger, and the one **context pointer** a **model-invoked** skill is forced to keep loaded at all times. Its mere presence _is_ the invocation axis: keep it and the skill is model-invoked (and reachable by other skills); delete it and the skill is **user-invoked**, reachable only by the human. The source of a model-invoked skill's **context load**.
|
||||||
|
|
||||||
|
_Avoid_: frontmatter, summary
|
||||||
|
|
||||||
|
### Context Pointer
|
||||||
|
|
||||||
|
A reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. The **description** is the top-level context pointer (context window → skill); pointers to disclosed files are the same object one level down. Its wording, not the target, decides _when_ the agent reaches — and _how reliably_. A must-have target behind a weakly worded pointer is a variance bug: fix the wording first, and inline the material only if sharpening fails.
|
||||||
|
|
||||||
|
_Avoid_: link, reference, import
|
||||||
|
|
||||||
|
### Context Load
|
||||||
|
|
||||||
|
The cost a **model-invoked** skill imposes on the agent's context window — its **description**, always loaded, spending both tokens and attention. What **user-invoked** skills escape by having no description, and the brake on splitting into more model-invoked skills.
|
||||||
|
|
||||||
|
_Avoid_: token cost, context bloat
|
||||||
|
|
||||||
|
### Cognitive Load
|
||||||
|
|
||||||
|
The cost a **user-invoked** skill imposes on the human — what they must hold in their head: which skills exist and when to reach for each (the human is the index). What **model-invocation** removes by being agent-discoverable, and the brake on splitting into more user-invoked skills. Not a cost to minimise: it is the price of human agency, the reason some skills stay user-invoked. Spend it where human judgement matters; remove it where it does not.
|
||||||
|
|
||||||
|
_Avoid_: human index, burden, overhead
|
||||||
|
|
||||||
|
### Router Skill
|
||||||
|
|
||||||
|
A **user-invoked** skill whose job is to point at your other user-invoked skills — naming each and when to reach for it — so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no **description**, so nothing but the human can reach them. The cure for **cognitive load** when user-invoked skills multiply.
|
||||||
|
|
||||||
|
_Avoid_: dispatcher, menu, registry, index, router procedure
|
||||||
|
|
||||||
|
### Granularity
|
||||||
|
|
||||||
|
How finely you divide skills. Finer division spends one of the two loads: more **model-invoked** skills spend **context load** (more descriptions crowding the window and competing for attention); more **user-invoked** skills spend **cognitive load** (more for the human to remember and reach for). Two cuts guide the division. By **invocation**, split off a model-invoked skill where you have a distinct **leading word** to trigger it — a trigger word you actually use in your prompts. By **sequence**, split a run of **steps** where a step's **post-completion steps** need hiding, since isolating it in its own context clears what follows. Beware the reverse: merging sequences exposes each step's post-completion steps to what follows, inviting premature completion.
|
||||||
|
|
||||||
|
_Avoid_: chunking, modularity
|
||||||
|
|
||||||
|
## Information Hierarchy
|
||||||
|
|
||||||
|
How a skill's content is arranged, and how far down the ladder each piece sits.
|
||||||
|
|
||||||
|
### Information Hierarchy
|
||||||
|
|
||||||
|
A skill's content ranked by how immediately the agent needs it — a single ladder, produced by two cuts: in-file or behind a pointer, and step or reference. The rungs:
|
||||||
|
|
||||||
|
- **Steps** — in-file, primary
|
||||||
|
- **Reference**, in-file — secondary
|
||||||
|
- **Reference**, disclosed — behind a **context pointer**
|
||||||
|
|
||||||
|
A skill with no **steps** uses just the bottom two rungs — often a legitimately flat peer-set (e.g. every rule of a review on one rung), which is a fine arrangement, not a smell. The hierarchy is independent of invocation: a skill can be model- or user-invoked whether it is all steps, all reference, or both. When a skill has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip — a variance lever, not just a legibility one. Keep the top of the ladder legible; push down it whatever you can.
|
||||||
|
|
||||||
|
_Avoid_: structure, organization, layout
|
||||||
|
|
||||||
|
### Steps
|
||||||
|
|
||||||
|
The ordered actions the agent performs — when a skill has them, the primary tier of its content, and the part that earns its place in SKILL.md. Not every skill has steps: a skill can be all steps (`tdd`), all **reference** (a review), or both, independent of invocation. Every step ends on a **completion criterion**, clear or vague.
|
||||||
|
|
||||||
|
_Avoid_: workflow, instructions, choreography
|
||||||
|
|
||||||
|
### Reference
|
||||||
|
|
||||||
|
Material the agent refers to on demand — definitions, facts, parameters, examples, conditional instructions. When a skill has **steps** it is secondary to them; when a skill has none it is the entire content; or it lives outside any skill entirely — see **External Reference**. Reached via **context pointers**, and the prime candidate for **progressive disclosure**.
|
||||||
|
|
||||||
|
_Avoid_: supporting material, docs, background
|
||||||
|
|
||||||
|
### External Reference
|
||||||
|
|
||||||
|
**Reference** that lives outside the skill system — a plain file, no **description**, no **steps**, not invocable — that any skill can point at. The home for shared reference that needn't fire on its own, and the only shared home two **user-invoked** skills can use, since neither has a description and so neither can fire the other.
|
||||||
|
|
||||||
|
_Avoid_: doc, resource, knowledge base
|
||||||
|
|
||||||
|
### Progressive Disclosure
|
||||||
|
|
||||||
|
Moving **reference** down the ladder — out of SKILL.md and behind a **context pointer** — so the top stays legible. Not primarily a token optimisation; it is how the **information hierarchy** is protected. Licensed by **branching**: disclose what only some branches need, inline what every path needs, and if a pointer fires unreliably on must-have material, sharpen its wording, and pull it back inline only if that fails.
|
||||||
|
|
||||||
|
_Avoid_: lazy loading, chunking
|
||||||
|
|
||||||
|
### Co-location
|
||||||
|
|
||||||
|
Keeping the material an agent needs at once in one place — a concept's definition, rules, and caveats under a single heading, not scattered across the file — so reading one part brings its neighbours with it. The within-file companion to the **Information Hierarchy**: the hierarchy ranks _how far down_ a piece sits; co-location decides _what sits beside it_ once there. There is no formula for the right format of a body of **reference**; the test is that a skill should read like documentation written for the agent, and grouped material reads that way where scattered material does not. Distinct from **Duplication**: that repeats one meaning in two places, where scattering fragments a single meaning across many.
|
||||||
|
|
||||||
|
_Avoid_: grouping, clustering, cohesion
|
||||||
|
|
||||||
|
### Sprawl
|
||||||
|
|
||||||
|
_Failure mode._ A skill that is simply too long — too many lines in SKILL.md — independent of whether they are stale or repeated. Even an all-live, all-unique skill can sprawl. It costs readability (the agent wades through more before it can act, and attention thins across the excess), maintainability (every extra line is one more to keep **relevant**), and tokens. The cure is the **information hierarchy**: push **reference** down behind **context pointers**, and split by **branch** or sequence so each path carries only what it needs. Distinct from **sediment** (length from stale accumulation) and **duplication** (length from repeated meaning) — sprawl is length itself, whatever its cause.
|
||||||
|
|
||||||
|
_Avoid_: bloat, length, size, verbosity
|
||||||
|
|
||||||
|
## Steering
|
||||||
|
|
||||||
|
The levers that shape the agent's runtime behaviour toward **Predictability**.
|
||||||
|
|
||||||
|
### Branch
|
||||||
|
|
||||||
|
A distinct way a skill can be invoked — a case the skill handles — so different runs take different paths through it. A skill with many steps may carry many branches; a linear one has none.
|
||||||
|
|
||||||
|
_Avoid_: path, case, fork
|
||||||
|
|
||||||
|
### Leading Word
|
||||||
|
|
||||||
|
A compact concept — also called a _Leitwort_ — already living in the model's pretraining, that the agent thinks with while running the skill. It encodes a behavioural principle in the fewest possible tokens by invoking priors the model already holds (e.g. _lesson_, _proximal zone of development_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition across the skill and anchors a whole region of behaviour. Coining your own works if you define it clearly, but a made-up word recruits no priors — you pay in definition tokens what a pretrained word gives free. Reach for an existing word first.
|
||||||
|
|
||||||
|
A leading word serves **predictability** twice. In the body it anchors **execution** — the agent reaches for the same behaviour every time the concept appears, and inside flat reference it focuses attention on a class of thing to look for, recruiting the right checks each run. In the **description** it anchors **invocation** — and not only within the skill: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the skill and fires it more reliably. Word a description with the leading words you actually use when you want the skill.
|
||||||
|
|
||||||
|
_Avoid_: keyword, term, motif
|
||||||
|
|
||||||
|
### Completion Criterion
|
||||||
|
|
||||||
|
The condition that tells the agent a unit of work is done — the target it judges against. Two properties make it a lever, not just a quality. Its **clarity** (can the agent tell done from not-done?) resists **premature completion** — a vague bound ("understanding reached") lets the agent declare done and slip to the next step; this axis needs _steps_ to bite, since premature completion is a between-steps failure. Its **demand** (how much it requires) sets **legwork** — "every modified model accounted for" forces thorough work where "produce a change list" does not — and this axis is _not_ step-bound: it can bind a body of flat reference too, which is how a skill with no steps still carries an exhaustiveness bar ("every rule applied"). The strongest criteria are both checkable and exhaustive.
|
||||||
|
|
||||||
|
_Avoid_: done condition, exit condition, stopping rule
|
||||||
|
|
||||||
|
### Legwork
|
||||||
|
|
||||||
|
The work an agent does behind the scenes within a single step — reading files, exploring the codebase, making changes, digging up what it needs rather than offloading to the user. It lives below the step structure: never written as its own step, latent in the wording, controlled by the agent rather than the skill. The within-step counterpart to **post-completion steps**' across-step pull. Raised by a **leading word** (_comprehensive_, _thorough_) or a **completion criterion** that demands the work be exhaustive — including the demand axis applied to flat reference, which is what drives a skill of flat reference to cover all its rungs. Goes thin either when that demand is missing or when **premature completion** cuts the step short.
|
||||||
|
|
||||||
|
_Avoid_: scope, effort, diligence, coverage
|
||||||
|
|
||||||
|
### Post-Completion Steps
|
||||||
|
|
||||||
|
The **steps** that follow the current step. Visible, they pull the agent forward into **premature completion** — the more it sees, the stronger the tug; the defence is to hide them by splitting the sequence of steps into two.
|
||||||
|
|
||||||
|
_Avoid_: horizon, fog of war, lookahead
|
||||||
|
|
||||||
|
### Premature Completion
|
||||||
|
|
||||||
|
_Failure mode._ Ending the current step before it is genuinely done, because the agent's attention slips to being done rather than to the work. A between-steps failure: it needs **steps** to occur — a skill with no steps that quits early isn't premature completion but thin **legwork** under an unmet demand. A tug-of-war between two forces: visible **post-completion steps** (the pull forward) and the **completion criterion**'s clarity (the resistance — a sharp, checkable bar holds; a vague one gives way). Fuzziness is the necessary condition: a sharp bound resists the pull no matter how many later steps are visible, so a step that never rushes needs no defending. Two levers hold a step that does, but reach for them in order: **sharpen the bound first** — it is local and cheap. Only when the criterion is irreducibly fuzzy _and_ you actually observe the rush do you **hide the later steps** — and hiding only works across a real context boundary (a user-invoked hand-off or a subagent dispatch; an inline model-invoked call leaves the later steps in context and clears nothing). One cause of thin legwork, but distinct from it: legwork can be thin even when a step runs to full completion.
|
||||||
|
|
||||||
|
_Avoid_: premature closure, the rush, rushing, shortcutting
|
||||||
|
|
||||||
|
## Pruning
|
||||||
|
|
||||||
|
Keeping a skill lean — each remedy paired with the failure it cures.
|
||||||
|
|
||||||
|
### Single Source of Truth
|
||||||
|
|
||||||
|
The desired state where each meaning lives in exactly one authoritative place, so a change to the skill's behaviour is a change in one place. **Duplication** is its violation.
|
||||||
|
|
||||||
|
_Avoid_: home, canonical location
|
||||||
|
|
||||||
|
### Duplication
|
||||||
|
|
||||||
|
_Failure mode._ The same meaning given more than one **single source of truth**. It costs maintenance (change one place, you must change the others), costs tokens, and inflates prominence — repeating a meaning weights it on the ladder past its real rank. The accidental inverse of a **leading word**, which raises attention on purpose by repeating a token, never the meaning.
|
||||||
|
|
||||||
|
_Avoid_: repetition, redundancy
|
||||||
|
|
||||||
|
### Relevance
|
||||||
|
|
||||||
|
Whether a line still bears on what the skill does — the lens for what to keep. A line loses relevance either by never bearing on the task (mere exposition, or a **branch** that should be disclosed) or by going stale: drifting out of date as the behaviour or world it describes changes. Shorter skills are easier to keep relevant, because each line is cheaper to check. Distinct from **no-op**: relevance asks whether a line bears on the task, not whether it changes behaviour.
|
||||||
|
|
||||||
|
_Avoid_: load-bearing, staleness, freshness
|
||||||
|
|
||||||
|
### Sediment
|
||||||
|
|
||||||
|
_Failure mode._ Layers of old content that settle in a skill and are never cleared, because adding feels safe and removing feels risky — so stale and irrelevant lines accumulate and you must core down through them to find what is still live. The default fate of any skill without a pruning discipline; the slow erosion of **relevance**, as opposed to **duplication**'s repeated meaning.
|
||||||
|
|
||||||
|
_Avoid_: accretion, bloat, cruft, rot
|
||||||
|
|
||||||
|
### No-Op
|
||||||
|
|
||||||
|
_Failure mode._ An instruction that changes nothing because the model already does it by default — you pay load to tell the agent what it would do anyway. The test: does a line change behaviour versus the default? A line can be perfectly **relevant** and still be a no-op. The same priors that make a **leading word** free make a no-op worthless.
|
||||||
|
|
||||||
|
A leading word is a _technique_; No-Op is a _verdict_ on a line — and they cross. A leading word too weak to beat the default is a no-op (_be thorough_ when the agent is already thorough-ish), and the fix is a stronger word that passes the verdict (_relentless_), not a different technique. So the No-Op test — does it change behaviour versus the default? — is also how you grade whether a leading word is earning its repetitions. This is model-relative, not reader-relative: two people disagreeing over whether a line is a no-op disagree about the default, and settle it by running the skill, not by debate.
|
||||||
|
|
||||||
|
_Avoid_: redundant instruction, restating the obvious, belaboring
|
||||||
84
.agents/skills/writing-great-skills/SKILL.md
Normal file
84
.agents/skills/writing-great-skills/SKILL.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
---
|
||||||
|
name: writing-great-skills
|
||||||
|
description: Reference for writing and editing skills well — the vocabulary and principles that make a skill predictable.
|
||||||
|
disable-model-invocation: true
|
||||||
|
metadata:
|
||||||
|
internal: true
|
||||||
|
---
|
||||||
|
|
||||||
|
A skill exists to wrangle determinism out of a stochastic system. **Predictability** — the agent taking the same _process_ every run, not producing the same output — is the root virtue; every lever below serves it.
|
||||||
|
|
||||||
|
**Bold terms** are defined in [`GLOSSARY.md`](GLOSSARY.md); look them up there for the full meaning.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
Two choices, trading different costs:
|
||||||
|
|
||||||
|
- A **model-invoked** skill keeps a **description**, so the agent can fire it autonomously _and_ other skills can reach it (you can still type its name too). It contributes to **context load** — the description sits in the window every turn. Mechanics: omit `disable-model-invocation`, and write a model-facing description with rich trigger phrasing ("Use when the user wants…, mentions…").
|
||||||
|
- A **user-invoked** skill strips the description from the agent's reach: only you, typing its name, can invoke it — and no other skill can. Zero context load, but it spends **cognitive load**: _you_ are the index that must remember it exists. Mechanics: set `disable-model-invocation: true`; the `description` becomes human-facing — a one-line summary, trigger lists stripped.
|
||||||
|
|
||||||
|
Pick model-invocation only when the agent must reach the skill on its own, or another skill must. If it only ever fires by hand, make it user-invoked and pay no context load.
|
||||||
|
|
||||||
|
When user-invoked skills multiply past what you can remember, that piled-up cognitive load is cured by a **router skill**: one user-invoked skill that names the others and when to reach for each.
|
||||||
|
|
||||||
|
## Writing the description
|
||||||
|
|
||||||
|
A model-invoked **description** does two jobs — state what the skill is, and list the **branches** that should trigger it. Every word increases **context load**, so a description earns even harder pruning than the body:
|
||||||
|
|
||||||
|
- **Front-load the skill's leading word** — the description is where it does its invocation work.
|
||||||
|
- **One trigger per branch.** Synonyms that rename a single branch are **duplication** — "build features using TDD … asks for test-first development" is one branch written twice. Collapse them; keep only genuinely distinct branches.
|
||||||
|
- **Cut identity that's already in the body.** Keep the description to triggers, plus any "when another skill needs…" reach clause.
|
||||||
|
|
||||||
|
## Information hierarchy
|
||||||
|
|
||||||
|
A skill is built from two content types — **steps** and **reference** — that mix freely: a skill can be all steps, all reference, or both. The core decision is which to use and where each sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
|
||||||
|
|
||||||
|
1. **In-skill step** — an ordered action in `SKILL.md`, the primary tier: what the agent does, in order. Each step ends on a **completion criterion**, the condition that tells the agent the work is done. Make it _checkable_ (can the agent tell done from not-done?) and, where it matters, _exhaustive_ ("every modified model accounted for", not "produce a change list") — a vague criterion invites **premature completion**.
|
||||||
|
2. **In-skill reference** — a definition, rule, or fact in `SKILL.md`, consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung) — a fine arrangement, not a smell. _This skill is all reference._
|
||||||
|
3. **External reference** — reference pushed out of `SKILL.md` into a separate file, reached by a **context pointer**, loaded only when the pointer fires. (Spans _disclosed_ reference — a sibling file like `GLOSSARY.md`, still part of the skill — through fully **external reference** that lives outside the skill system and any skill can point at.)
|
||||||
|
|
||||||
|
A demanding completion criterion drives thorough **legwork** — the digging the agent does within the work — whether the skill has steps or not, since "every rule applied" binds flat reference just as "every step done" binds a sequence.
|
||||||
|
|
||||||
|
Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
|
||||||
|
|
||||||
|
**Progressive disclosure** is the move down the ladder — out of `SKILL.md` into a linked file — so the top stays legible. Mechanics: a linked `.md` file in the skill folder, named for what it holds (this skill discloses its full definitions to `GLOSSARY.md`). Some skills are used in more than one way, and each distinct way is a **branch** — different runs taking different paths through the skill. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. A **context pointer**'s _wording_, not its target, decides when and how reliably the agent reaches the material.
|
||||||
|
|
||||||
|
Where the ladder decides _how far down_ a piece sits, **co-location** decides _what sits beside it_ once there: keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it.
|
||||||
|
|
||||||
|
## When to split
|
||||||
|
|
||||||
|
**Granularity** is how finely you divide skills, and each cut spends one of the two loads, so split only when the cut earns it. Two cuts:
|
||||||
|
|
||||||
|
- **By invocation** — split off a **model-invoked** skill when you have a distinct **leading word** that should trigger it on its own, or another skill must reach it. You pay **context load** for the new always-loaded **description**, so that independent reach has to be worth it.
|
||||||
|
- **By sequence** — split a run of **steps** when the steps still ahead (a step's **post-completion steps**) tempt the agent to rush the one in front of it (**premature completion**). Keeping them out of view encourages the agent to do more **legwork** on the current task.
|
||||||
|
|
||||||
|
## Pruning
|
||||||
|
|
||||||
|
Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit.
|
||||||
|
|
||||||
|
Check every line for **relevance**: does it still bear on what the skill does?
|
||||||
|
|
||||||
|
Then hunt **no-ops** sentence by sentence, not just line by line: run the no-op test on each sentence in isolation, and when one fails, delete the whole sentence rather than trim words from it. Be aggressive — most prose that fails should go, not be rewritten.
|
||||||
|
|
||||||
|
## Leading words
|
||||||
|
|
||||||
|
A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the skill (e.g. _lesson_, _fog of war_, _tracer bullets_). Repeated throughout the text (though not necessarily - a strong leading word might only be needed once), it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds.
|
||||||
|
|
||||||
|
It serves predictability twice. In the body it anchors _execution_: the agent reaches for the same behaviour every time the word appears. In the description it anchors _invocation_: when the same word lives in your prompts, docs, and code, the agent links that shared language to the skill and fires it more reliably.
|
||||||
|
|
||||||
|
Hunt for opportunities to refactor skills to use leading words. A triad spelled out at three sites (**duplication**), a description spending a sentence to gesture at one idea — each is a passage begging to **collapse** into a single token. Examples include:
|
||||||
|
|
||||||
|
- "fast, deterministic, low-overhead" -> _tight_ — one quality restated across a phase — into a single pretrained word (a _tight_ loop).
|
||||||
|
- "a loop you believe in" -> _red_ — converts a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
|
||||||
|
|
||||||
|
You win twice over: fewer tokens, _and_ a sharper hook for the agent to hang its thinking on. Assume every skill is carrying restatements that leading words retire — go find them.
|
||||||
|
|
||||||
|
## Failure modes
|
||||||
|
|
||||||
|
Use these to diagnose issues the user may be having with the skill.
|
||||||
|
|
||||||
|
- **Premature completion** — ending a step before it's genuinely done, attention slipping to _being done_. Defence, in order: sharpen the completion criterion first (cheap, local); only if it is irreducibly fuzzy _and_ you observe the rush, hide the post-completion steps by splitting (the sequence cut).
|
||||||
|
- **Duplication** — the same meaning in more than one place. Costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank.
|
||||||
|
- **Sediment** — stale layers that settle because adding feels safe and removing feels risky. The default fate of any skill without a pruning discipline.
|
||||||
|
- **Sprawl** — a skill simply too long, even when every line is live and unique. Hurts readability and maintainability and wastes tokens. The cure is the ladder: disclose **reference** behind pointers, and split by **branch** or sequence so each path carries only what it needs.
|
||||||
|
- **No-op** — a line the model already obeys by default, so you pay load to say nothing. The test: does it change behaviour versus the default? A weak leading word (_be thorough_ when the agent is already thorough-ish) is a no-op; the fix is a stronger word (_relentless_), not a different technique.
|
||||||
126
.agents/skills/writing-opencode-plugins/SKILL.md
Normal file
126
.agents/skills/writing-opencode-plugins/SKILL.md
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
---
|
||||||
|
name: writing-opencode-plugins
|
||||||
|
description: OpenCode plugins, @opencode-ai/plugin, @opencode-ai/plugin/tui, plugin hooks, custom tools, TUI routes, slots, keymaps, and packaging. Use when creating, editing, reviewing, testing, or publishing server or TUI plugins for OpenCode.
|
||||||
|
metadata:
|
||||||
|
internal: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Writing OpenCode Plugins
|
||||||
|
|
||||||
|
Use this skill to implement production-quality OpenCode plugins. Treat the repository's exported types and runtime as authoritative because plugin APIs are evolving and public docs may lag.
|
||||||
|
|
||||||
|
## Start Here
|
||||||
|
|
||||||
|
1. Decide which runtime owns the feature.
|
||||||
|
2. Read the relevant public type before writing code.
|
||||||
|
3. Find one focused in-repository example using the same API.
|
||||||
|
4. Implement the smallest target-specific module.
|
||||||
|
5. Test loading, behavior, failure, and cleanup in the owning package.
|
||||||
|
|
||||||
|
| Need | Plugin target | Import | Configuration |
|
||||||
|
| -------------------------------------------------------------------- | --------------------------- | ------------------------------ | ---------------------------------------------------------------- |
|
||||||
|
| Hooks, tools, auth, providers, model parameters, shell environment | Server | `@opencode-ai/plugin` | `opencode.json` or auto-discovered `.opencode/plugins/*.{ts,js}` |
|
||||||
|
| Commands, keybindings, routes, dialogs, slots, themes, notifications | TUI | `@opencode-ai/plugin/tui` | Explicit `tui.json` `plugin` entry |
|
||||||
|
| Both | Two target-only entrypoints | Both imports in separate files | Package exports `./server` and `./tui` |
|
||||||
|
|
||||||
|
Never export `server` and `tui` from the same module. Do not use server event hooks as a substitute for interactive TUI APIs.
|
||||||
|
|
||||||
|
## Verify The Current Contract
|
||||||
|
|
||||||
|
Read these files before implementing unfamiliar behavior:
|
||||||
|
|
||||||
|
- `packages/plugin/src/index.ts`: authoritative server plugin and hook types.
|
||||||
|
- `packages/plugin/src/tool.ts`: custom tool schema, context, permission, metadata, attachments, and result types.
|
||||||
|
- `packages/plugin/src/tui.ts`: authoritative TUI API and module types.
|
||||||
|
- `packages/opencode/specs/tui-plugins.md`: TUI loading, packaging, lifecycle, and API semantics.
|
||||||
|
- `packages/opencode/src/plugin/shared.ts`: target validation, IDs, and entrypoint resolution.
|
||||||
|
- `packages/opencode/src/plugin/loader.ts`: install, compatibility, and import behavior.
|
||||||
|
|
||||||
|
If these disagree with examples or website docs, follow exported types and runtime behavior, then update stale documentation when appropriate.
|
||||||
|
|
||||||
|
## Choose A Module Shape
|
||||||
|
|
||||||
|
Prefer the explicit module object for new server plugins:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import type { Plugin, PluginModule } from '@opencode-ai/plugin';
|
||||||
|
|
||||||
|
const server: Plugin = async ({ client, directory }, options) => ({
|
||||||
|
dispose: async () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
id: 'acme.example',
|
||||||
|
server,
|
||||||
|
} satisfies PluginModule & { id: string };
|
||||||
|
```
|
||||||
|
|
||||||
|
Legacy server-only local plugins may export a plugin function directly. In a legacy module every distinct named export is interpreted as a plugin, so do not export unrelated constants. Prefer a default module object for new code.
|
||||||
|
|
||||||
|
TUI plugins always use a default module object:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
/** @jsxImportSource @opentui/solid */
|
||||||
|
import type { TuiPlugin, TuiPluginModule } from '@opencode-ai/plugin/tui';
|
||||||
|
|
||||||
|
const tui: TuiPlugin = async (api) => {
|
||||||
|
api.ui.toast({ message: 'Plugin loaded' });
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
id: 'acme.example-tui',
|
||||||
|
tui,
|
||||||
|
} satisfies TuiPluginModule & { id: string };
|
||||||
|
```
|
||||||
|
|
||||||
|
File plugins require a stable, non-empty `id`. npm plugins may derive the ID from the package name, but an explicit namespaced ID makes state, diagnostics, and collision handling clearer.
|
||||||
|
|
||||||
|
## Engineering Rules
|
||||||
|
|
||||||
|
- Use TypeScript and `satisfies` against the public plugin type.
|
||||||
|
- Parse and validate `options`; they arrive as unvalidated `Record<string, unknown>`.
|
||||||
|
- Namespace plugin IDs, command IDs, route names, modes, slot names, and shared KV keys.
|
||||||
|
- Use the directory supplied by the plugin or tool context, not `process.cwd()`.
|
||||||
|
- Honor `AbortSignal` for long-running or cancellable work.
|
||||||
|
- Use `client.app.log()` for structured server logging instead of `console.log`.
|
||||||
|
- Request permission before sensitive or consequential custom-tool work.
|
||||||
|
- Keep notifications privacy-safe; do not expose prompts, secrets, paths, commands, or raw errors.
|
||||||
|
- Register only needed hooks and UI resources. Avoid broad event subscriptions when a specific hook exists.
|
||||||
|
- Make cleanup bounded, idempotent, and safe after partial initialization.
|
||||||
|
- Do not depend on undocumented load order to resolve ownership conflicts.
|
||||||
|
|
||||||
|
## Testing Workflow
|
||||||
|
|
||||||
|
Server plugin tests belong under `packages/opencode/test/plugin/` or the closest owning subsystem. TUI runtime tests belong under `packages/opencode/test/cli/tui/`; component-level TUI tests may belong in `packages/tui`.
|
||||||
|
|
||||||
|
Test at least:
|
||||||
|
|
||||||
|
- valid loading and target/entrypoint selection;
|
||||||
|
- configured options and malformed options;
|
||||||
|
- the observable behavior, not a duplicate of implementation logic;
|
||||||
|
- abort, failure, and partial-initialization behavior;
|
||||||
|
- cleanup or disposal;
|
||||||
|
- duplicate IDs or registrations when relevant;
|
||||||
|
- local file and npm packaging behavior when publishing.
|
||||||
|
|
||||||
|
Run tests from the package directory, never the repository root. Use `bun typecheck` from the owning package for type checking.
|
||||||
|
|
||||||
|
## Review Checklist
|
||||||
|
|
||||||
|
- The feature is in the correct server or TUI runtime.
|
||||||
|
- Module shape and import path match the target.
|
||||||
|
- Server and TUI entrypoints are separate.
|
||||||
|
- IDs and persistent keys are stable and namespaced.
|
||||||
|
- Options and external data are validated.
|
||||||
|
- Hook output mutation preserves other plugins' changes.
|
||||||
|
- Tools use context directory, permission, metadata, and abort correctly.
|
||||||
|
- TUI keybindings are mode-gated unless intentionally global.
|
||||||
|
- TUI resources and custom side effects are disposed.
|
||||||
|
- Package exports, `engines.opencode`, and config target are correct.
|
||||||
|
- Tests cover behavior and lifecycle.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Server plugins](references/server-plugins.md): hooks, custom tools, lifecycle, and examples.
|
||||||
|
- [TUI plugins](references/tui-plugins.md): keymaps, routes, dialogs, slots, state, and lifecycle.
|
||||||
|
- [Packaging and testing](references/packaging-testing.md): config, package exports, compatibility, and test locations.
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
# Packaging And Testing
|
||||||
|
|
||||||
|
## Local Configuration
|
||||||
|
|
||||||
|
Server plugin in `opencode.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
"plugin": ["./plugins/server.ts", ["package-name", { "key": "value" }]]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Server files under `.opencode/plugin/` or `.opencode/plugins/` are also auto-discovered. Relative configured paths resolve from the config file that declared them.
|
||||||
|
|
||||||
|
TUI plugin in `tui.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/tui.json",
|
||||||
|
"plugin": [["./plugins/tui.tsx", { "key": "value" }]],
|
||||||
|
"plugin_enabled": {
|
||||||
|
"acme.demo": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`plugin_enabled` uses the resolved plugin ID, not its package or file spec. Persisted runtime enablement can override config.
|
||||||
|
|
||||||
|
After editing plugin or config-time files, restart OpenCode; the running session keeps its loaded configuration and modules.
|
||||||
|
|
||||||
|
## npm Package Shape
|
||||||
|
|
||||||
|
Publish separate target-only entrypoints:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "@acme/opencode-plugin",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
"./server": {
|
||||||
|
"import": "./dist/server.js",
|
||||||
|
"config": { "serverOption": true }
|
||||||
|
},
|
||||||
|
"./tui": {
|
||||||
|
"import": "./dist/tui.js",
|
||||||
|
"config": { "tuiOption": true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"opencode": "^1.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opencode-ai/plugin": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- Server resolution prefers `exports["./server"]` and may fall back to `main`.
|
||||||
|
- TUI resolution requires `exports["./tui"]`; it does not use `main`.
|
||||||
|
- A package supporting both targets needs separate source and output files.
|
||||||
|
- `exports[target].config` may provide default options written during first install.
|
||||||
|
- Use `engines.opencode` to declare tested compatibility.
|
||||||
|
- npm compatibility is checked; local file plugins bypass the engine check.
|
||||||
|
- Pin package versions when reproducibility matters.
|
||||||
|
- Plugin package install runs with lifecycle scripts disabled, so do not require `postinstall`.
|
||||||
|
- Keep resolved entrypoints and theme paths inside the package directory.
|
||||||
|
|
||||||
|
Theme-only TUI packages may use `oc-themes`; consult `packages/opencode/specs/tui-plugins.md` for path and synchronization rules.
|
||||||
|
|
||||||
|
## Resolution And Identity
|
||||||
|
|
||||||
|
- npm declarations deduplicate by package name; higher-precedence/later declarations win.
|
||||||
|
- File server and TUI specs have target-specific resolution behavior.
|
||||||
|
- External modules may resolve/import in parallel, but activate sequentially.
|
||||||
|
- IDs must not collide with built-ins or other loaded plugins.
|
||||||
|
- Dynamic import failures are effectively permanent for the current process because Bun caches them.
|
||||||
|
- `--pure` or `OPENCODE_PURE` skips external plugins.
|
||||||
|
|
||||||
|
Read `packages/opencode/src/plugin/shared.ts`, `loader.ts`, and `install.ts` before changing packaging behavior.
|
||||||
|
|
||||||
|
## Test Locations
|
||||||
|
|
||||||
|
Server plugin coverage:
|
||||||
|
|
||||||
|
- `packages/opencode/test/plugin/trigger.test.ts`: hook sequencing and failures.
|
||||||
|
- `packages/opencode/test/plugin/loader-shared.test.ts`: resolution and module validation.
|
||||||
|
- `packages/opencode/test/plugin/shared.test.ts`: shared target rules.
|
||||||
|
- `packages/opencode/test/plugin/install.test.ts`: package install and config patching.
|
||||||
|
- `packages/opencode/test/plugin/install-concurrency.test.ts`: concurrent writes.
|
||||||
|
- `packages/opencode/test/plugin/auth-override.test.ts`: auth precedence.
|
||||||
|
- `packages/opencode/test/tool/registry.test.ts`: schemas, results, and attachments.
|
||||||
|
|
||||||
|
TUI plugin coverage:
|
||||||
|
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-loader.test.ts`: loading and ordering.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-loader-entrypoint.test.ts`: target entrypoints.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-lifecycle.test.ts`: rollback and cleanup.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-toggle.test.ts`: persisted enablement.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-add.test.ts`: runtime addition.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-install.test.ts`: installation.
|
||||||
|
- `packages/opencode/test/cli/tui/plugin-loader-pure.test.ts`: pure mode.
|
||||||
|
|
||||||
|
Use fixture helpers under `packages/opencode/test/fixture/` rather than reimplementing the loader in tests.
|
||||||
|
|
||||||
|
## Verification Commands
|
||||||
|
|
||||||
|
Run from the owning package, never the repository root:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd packages/opencode
|
||||||
|
bun typecheck
|
||||||
|
bun test test/plugin/trigger.test.ts
|
||||||
|
bun test test/cli/tui/plugin-lifecycle.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Select the smallest relevant tests first, then broader plugin suites. For interactive TUI verification, follow `packages/opencode/AGENTS.md`: run `bun dev` in detached `tmux`, capture output, and explicitly stop the session.
|
||||||
|
|
||||||
|
## Publishing Checklist
|
||||||
|
|
||||||
|
- Build output is ESM-compatible and contains no source-only path aliases.
|
||||||
|
- Every advertised target has the correct package export.
|
||||||
|
- Each target module exports only its own target shape.
|
||||||
|
- Peer/runtime dependencies are classified correctly.
|
||||||
|
- `engines.opencode` matches tested versions.
|
||||||
|
- Default options are backward-compatible and validated at runtime.
|
||||||
|
- Local file, pinned npm, and bare npm specs have been considered.
|
||||||
|
- Loading, failure, cleanup, and upgrade behavior are tested.
|
||||||
|
- README examples match the exported API and config target.
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
# Server Plugins
|
||||||
|
|
||||||
|
## Contract And Lifecycle
|
||||||
|
|
||||||
|
The public contract is `packages/plugin/src/index.ts`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type Plugin = (input: PluginInput, options?: Record<string, unknown>) => Promise<Hooks>
|
||||||
|
```
|
||||||
|
|
||||||
|
`PluginInput` provides the SDK `client`, `project`, `directory`, `worktree`, `serverUrl`, Bun shell `$`, and experimental workspace registration.
|
||||||
|
|
||||||
|
The server runtime is `packages/opencode/src/plugin/index.ts`.
|
||||||
|
|
||||||
|
- Built-in plugins initialize before external plugins.
|
||||||
|
- External modules may resolve concurrently, but activation is sequential for deterministic hook order.
|
||||||
|
- `config` hooks run sequentially against the mutable merged config.
|
||||||
|
- `event` subscribes to location-filtered events and is fire-and-forget.
|
||||||
|
- Ordinary hooks run sequentially and share a mutable output object.
|
||||||
|
- Ordinary hook failures propagate and stop later hooks for that trigger.
|
||||||
|
- Initialization, config, and disposal failures are isolated and logged by the host.
|
||||||
|
- `dispose` runs when the per-directory plugin scope closes.
|
||||||
|
|
||||||
|
Mutate hook output in place. Preserve values contributed by earlier plugins: append arrays, merge maps, and change only fields the plugin owns.
|
||||||
|
|
||||||
|
## Hook Selection
|
||||||
|
|
||||||
|
Use the narrowest hook that expresses the behavior:
|
||||||
|
|
||||||
|
| Goal | Hook |
|
||||||
|
| ---------------------------------- | --------------------------------- |
|
||||||
|
| Observe SDK events | `event` |
|
||||||
|
| Modify merged configuration | `config` |
|
||||||
|
| Add tools | `tool` |
|
||||||
|
| Add provider authentication | `auth` |
|
||||||
|
| Add or change provider models | `provider` |
|
||||||
|
| Modify incoming user message | `chat.message` |
|
||||||
|
| Modify LLM parameters or headers | `chat.params`, `chat.headers` |
|
||||||
|
| Modify command parts | `command.execute.before` |
|
||||||
|
| Validate or rewrite tool arguments | `tool.execute.before` |
|
||||||
|
| Transform tool presentation/result | `tool.execute.after` |
|
||||||
|
| Modify model-facing tool schemas | `tool.definition` |
|
||||||
|
| Add shell environment variables | `shell.env` |
|
||||||
|
| Influence permission decisions | `permission.ask` |
|
||||||
|
| Customize compaction | `experimental.session.compacting` |
|
||||||
|
|
||||||
|
Read the complete `Hooks` interface before using experimental hooks.
|
||||||
|
|
||||||
|
## Custom Tools
|
||||||
|
|
||||||
|
Use `tool()` and Zod schemas from `tool.schema`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { type Plugin, tool } from "@opencode-ai/plugin"
|
||||||
|
|
||||||
|
export default (async () => ({
|
||||||
|
tool: {
|
||||||
|
lookup_issue: tool({
|
||||||
|
description: "Look up one issue by numeric ID",
|
||||||
|
args: {
|
||||||
|
id: tool.schema.number().int().positive().describe("Issue ID"),
|
||||||
|
},
|
||||||
|
async execute(args, context) {
|
||||||
|
await context.ask({
|
||||||
|
permission: "lookup_issue",
|
||||||
|
patterns: [String(args.id)],
|
||||||
|
always: ["*"],
|
||||||
|
metadata: { id: args.id },
|
||||||
|
})
|
||||||
|
context.metadata({ title: `Issue ${args.id}` })
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: `Issue ${args.id}`,
|
||||||
|
output: "Result",
|
||||||
|
metadata: { id: args.id },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})) satisfies Plugin
|
||||||
|
```
|
||||||
|
|
||||||
|
Tool rules:
|
||||||
|
|
||||||
|
- Write descriptions for the model, including when to use the tool and important constraints.
|
||||||
|
- Describe arguments individually and constrain them in the schema.
|
||||||
|
- Use `context.directory` and `context.worktree` for path resolution.
|
||||||
|
- Pass `context.abort` into cancellable I/O.
|
||||||
|
- Call `context.ask()` before performing work covered by a permission boundary.
|
||||||
|
- Use `context.metadata()` for in-progress presentation; return final metadata in the result.
|
||||||
|
- Return attachments only as declared file attachments with a MIME type and URL.
|
||||||
|
- Keep output useful and bounded. The host may truncate large results and add truncation metadata.
|
||||||
|
|
||||||
|
Plugin tools with built-in IDs take precedence, but overriding built-ins should be explicit and tested.
|
||||||
|
|
||||||
|
## Auth And Providers
|
||||||
|
|
||||||
|
Use existing built-ins as references rather than inventing OAuth behavior:
|
||||||
|
|
||||||
|
- `packages/opencode/src/plugin/azure.ts`: simple API-key prompt.
|
||||||
|
- `packages/opencode/src/plugin/xai.ts`: OAuth, refresh, and custom fetch behavior.
|
||||||
|
- `packages/opencode/src/plugin/openai/codex.ts`: auth plus chat parameter hooks.
|
||||||
|
- `packages/opencode/src/plugin/github-copilot/copilot.ts`: full auth/provider integration.
|
||||||
|
|
||||||
|
Do not log credentials, tokens, authorization codes, provider headers, or raw auth responses. Preserve provider identity and refresh semantics defined by `AuthHook`.
|
||||||
|
|
||||||
|
## Useful Examples
|
||||||
|
|
||||||
|
- `.opencode/plugins/model-task.ts`: custom subagent tool with permission, abort, metadata, and SDK calls when present in the worktree.
|
||||||
|
- `packages/plugin/src/example.ts`: minimal package example.
|
||||||
|
- `packages/opencode/test/fixture/agent-plugin.ts`: config mutation fixture.
|
||||||
|
- `packages/opencode/src/plugin/*.ts`: built-in auth/provider implementations.
|
||||||
|
|
||||||
|
## Common Failures
|
||||||
|
|
||||||
|
- Exporting constants beside legacy plugin functions: every exported value may be treated as a plugin.
|
||||||
|
- Using `process.cwd()` in a multi-directory process.
|
||||||
|
- Replacing a shared output map or array and deleting earlier plugin contributions.
|
||||||
|
- Forgetting that `event` is not awaited like ordinary hooks.
|
||||||
|
- Assuming thrown hook errors are isolated.
|
||||||
|
- Installing a missing dependency after a dynamic import failed and expecting the same process to recover; Bun caches failed imports.
|
||||||
|
- Trusting options without validation.
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# TUI Plugins
|
||||||
|
|
||||||
|
## Contract And Loading
|
||||||
|
|
||||||
|
The public contract is `packages/plugin/src/tui.ts`; technical behavior is documented in `packages/opencode/specs/tui-plugins.md`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type TuiPlugin = (api: TuiPluginApi, options: Record<string, unknown> | undefined, meta: TuiPluginMeta) => Promise<void>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Import from `@opencode-ai/plugin/tui`.
|
||||||
|
- Export one default `{ id?, tui }` object. Named exports are ignored by the loader.
|
||||||
|
- File plugins require an explicit non-empty ID.
|
||||||
|
- Configure TUI plugins explicitly in `tui.json`; there is no directory auto-discovery.
|
||||||
|
- JSX uses OpenTUI Solid, normally with `/** @jsxImportSource @opentui/solid */`.
|
||||||
|
- TUI packages resolve only `exports["./tui"]`; they do not fall back to package `main` or root exports.
|
||||||
|
|
||||||
|
## API Routing
|
||||||
|
|
||||||
|
| Need | API |
|
||||||
|
| -------------------------------- | ------------------------------------------ |
|
||||||
|
| Commands and shortcuts | `api.keymap.registerLayer(...)` |
|
||||||
|
| Temporary input context | `api.mode.push(...)` |
|
||||||
|
| Full-screen UI | `api.route.register(...)`, `navigate(...)` |
|
||||||
|
| Host dialogs and toast | `api.ui.dialog`, `Dialog*`, `toast(...)` |
|
||||||
|
| Reuse the host prompt | `api.ui.Prompt` |
|
||||||
|
| Inject host UI | `api.slots.register(...)` |
|
||||||
|
| Theme tokens and switching | `api.theme` |
|
||||||
|
| Synced sessions/providers/status | `api.state` |
|
||||||
|
| SDK operations | `api.client` |
|
||||||
|
| TUI event stream | `api.event.on(...)` |
|
||||||
|
| Persistent shared values | `api.kv` |
|
||||||
|
| Host-mediated notification/sound | `api.attention` |
|
||||||
|
| Extra cleanup | `api.lifecycle.onDispose(...)` |
|
||||||
|
|
||||||
|
Do not use deprecated `api.command` in new plugins. Register commands and bindings through keymap layers.
|
||||||
|
|
||||||
|
## Commands And Modes
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
api.keymap.registerLayer({
|
||||||
|
mode: "base",
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
name: "acme.demo.open",
|
||||||
|
title: "Open demo",
|
||||||
|
category: "Plugin",
|
||||||
|
namespace: "palette",
|
||||||
|
slashName: "demo",
|
||||||
|
run() {
|
||||||
|
api.route.navigate("acme.demo")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
bindings: [{ key: "ctrl+shift+m", cmd: "acme.demo.open", desc: "Open demo" }],
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Built-in modes are `base`, `modal`, and `autocomplete`. A layer without `mode` remains active across dialogs and autocomplete, so omit mode only for intentionally global behavior.
|
||||||
|
|
||||||
|
For plugin-owned full-screen interaction, push a namespaced mode inside the component and dispose it with Solid cleanup:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { onCleanup } from "solid-js"
|
||||||
|
|
||||||
|
const pop_mode = api.mode.push("acme.demo")
|
||||||
|
onCleanup(pop_mode)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Routes, Dialogs, And Slots
|
||||||
|
|
||||||
|
- Reserve `home` and `session` for host routes.
|
||||||
|
- Namespace route names; duplicate routes are last-registration-wins.
|
||||||
|
- Unknown routes render fallback UI rather than throwing.
|
||||||
|
- Use host dialog components for standard interactions and `api.ui.dialog.replace()` for custom dialog content.
|
||||||
|
- Use route params for serializable navigation state; keep component-local transient state in Solid primitives when appropriate.
|
||||||
|
- `api.slots.register(...)` returns an assigned ID, not an unregister function.
|
||||||
|
- Slot registration and other host API resources are scope-tracked automatically.
|
||||||
|
- Read current slot names and props from `TuiHostSlotMap`, not copied lists.
|
||||||
|
|
||||||
|
## State And Persistence
|
||||||
|
|
||||||
|
- `api.tuiConfig` and `api.state` are live views, not initialization snapshots.
|
||||||
|
- `api.kv` is shared by all plugins. Prefix every key with the plugin ID.
|
||||||
|
- Check readiness where the API exposes it.
|
||||||
|
- Persist only user preferences or durable plugin state, not derived host state.
|
||||||
|
- Runtime enablement in KV overrides `tui.json` on startup.
|
||||||
|
|
||||||
|
`meta.state` is `first`, `updated`, or `same`. Use it for bounded migration or asset synchronization, not normal rendering behavior.
|
||||||
|
|
||||||
|
## Lifecycle
|
||||||
|
|
||||||
|
The host automatically scope-tracks commands, keymap resources, routes, event subscriptions, slots, pushed modes, and sound packs.
|
||||||
|
|
||||||
|
- `api.lifecycle.signal` aborts before cleanup begins.
|
||||||
|
- Use `api.lifecycle.onDispose()` for timers, sockets, file watchers, workers, or other plugin-owned resources.
|
||||||
|
- Initialization failure rolls back tracked resources and does not prevent later plugins from loading.
|
||||||
|
- Cleanup is reverse-order, awaited, idempotent, and constrained by a total five-second budget.
|
||||||
|
- Keep cleanup fast and independently safe after partial initialization.
|
||||||
|
|
||||||
|
## UI Quality
|
||||||
|
|
||||||
|
- Use `api.theme.current` tokens instead of hard-coded colors.
|
||||||
|
- Use `api.keys` to display shortcuts according to host formatting.
|
||||||
|
- Make routes responsive to terminal dimensions and usable with keyboard-only input.
|
||||||
|
- Avoid taking over global shortcuts without a strong reason.
|
||||||
|
- Prefer host dialogs, prompts, and slots over visually inconsistent reimplementations.
|
||||||
|
- Send attention through `api.attention.notify()` so the host owns focus, notification, and sound policy.
|
||||||
|
- Keep notification text privacy-safe.
|
||||||
|
|
||||||
|
## Useful Examples
|
||||||
|
|
||||||
|
- `.opencode/plugins/tui-smoke.tsx`: broad API smoke implementation.
|
||||||
|
- `packages/tui/src/feature-plugins/system/which-key.tsx`: focused keymap UI.
|
||||||
|
- `packages/tui/src/feature-plugins/system/notifications.ts`: attention behavior.
|
||||||
|
- `packages/tui/src/feature-plugins/system/diff-viewer.tsx`: route/UI integration.
|
||||||
|
- `packages/tui/src/feature-plugins/home/tips.tsx`: host slot usage.
|
||||||
|
- `packages/tui/src/feature-plugins/sidebar/context.tsx`: sidebar extension.
|
||||||
|
|
||||||
|
## Common Failures
|
||||||
|
|
||||||
|
- Expecting `.opencode/plugins` auto-discovery for TUI modules.
|
||||||
|
- Exporting `{ server, tui }` from one module.
|
||||||
|
- Omitting the default export, or relying on named exports.
|
||||||
|
- Omitting an ID for a file plugin.
|
||||||
|
- Registering an ungated keymap layer accidentally active in modal/autocomplete modes.
|
||||||
|
- Treating KV as plugin-private.
|
||||||
|
- Treating `slots.register()` as returning a disposer.
|
||||||
|
- Expecting `plugins.install()` to activate a plugin; installation and runtime addition are separate.
|
||||||
|
- Leaking timers or network resources because host tracking only covers host registrations.
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
||||||
"changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/mcp" }],
|
"changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/ai-tools" }],
|
||||||
"commit": false,
|
"commit": false,
|
||||||
"fixed": [],
|
"fixed": [],
|
||||||
"linked": [],
|
"linked": [],
|
||||||
"access": "public",
|
"access": "public",
|
||||||
"baseBranch": "main",
|
"baseBranch": "main",
|
||||||
"updateInternalDependencies": "patch",
|
"updateInternalDependencies": "patch",
|
||||||
"ignore": []
|
"ignore": ["!@sveltejs/mcp", "!@sveltejs/opencode"]
|
||||||
}
|
}
|
||||||
|
|||||||
22
.claude-plugin/marketplace.json
Normal file
22
.claude-plugin/marketplace.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "svelte",
|
||||||
|
"owner": {
|
||||||
|
"name": "Svelte"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "svelte",
|
||||||
|
"source": "./plugins/claude/svelte",
|
||||||
|
"description": "A plugin for all things Svelte development, MCP, skills, and more.",
|
||||||
|
"lspServers": {
|
||||||
|
"svelte": {
|
||||||
|
"command": "svelteserver",
|
||||||
|
"args": ["--stdio"],
|
||||||
|
"extensionToLanguage": {
|
||||||
|
".svelte": "svelte"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
13
.cursor-plugin/marketplace.json
Normal file
13
.cursor-plugin/marketplace.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "svelte",
|
||||||
|
"owner": {
|
||||||
|
"name": "Svelte"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "svelte",
|
||||||
|
"source": "./plugins/cursor/svelte",
|
||||||
|
"description": "A plugin for all things Svelte development, MCP, skills, and more."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
open_collective: svelte
|
||||||
12
.github/workflows/check.yml
vendored
12
.github/workflows/check.yml
vendored
@@ -13,17 +13,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
|
||||||
- name: Setup pnpm
|
- name: Setup pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
|
||||||
with:
|
|
||||||
version: 10.18.1
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '24'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -32,6 +30,4 @@ jobs:
|
|||||||
- name: Run type check
|
- name: Run type check
|
||||||
run: pnpm run check
|
run: pnpm run check
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: file:test.db
|
|
||||||
DATABASE_TOKEN: dummy-key
|
|
||||||
VOYAGE_API_KEY: dummy-key
|
VOYAGE_API_KEY: dummy-key
|
||||||
|
|||||||
12
.github/workflows/lint.yml
vendored
12
.github/workflows/lint.yml
vendored
@@ -13,17 +13,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
|
||||||
- name: Setup pnpm
|
- name: Setup pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
|
||||||
with:
|
|
||||||
version: 10.18.1
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '24'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -32,6 +30,4 @@ jobs:
|
|||||||
- name: Run linting
|
- name: Run linting
|
||||||
run: pnpm run lint
|
run: pnpm run lint
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: file:test.db
|
|
||||||
VOYAGE_API_KEY: dummy-key
|
VOYAGE_API_KEY: dummy-key
|
||||||
DATABASE_TOKEN: dummy-key
|
|
||||||
|
|||||||
23
.github/workflows/publish-mcp.yml
vendored
23
.github/workflows/publish-mcp.yml
vendored
@@ -2,9 +2,10 @@ name: Publish to MCP Registry
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
secrets:
|
||||||
permissions:
|
MCP_KEY:
|
||||||
id-token: write # OpenID Connect token needed for MCP registry authentication
|
required: true
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-mcp:
|
publish-mcp:
|
||||||
@@ -12,17 +13,19 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
|
||||||
- name: Publish to MCP Registry
|
- name: Publish to MCP Registry
|
||||||
working-directory: packages/mcp-stdio
|
working-directory: packages/mcp-stdio
|
||||||
|
env:
|
||||||
|
MCP_KEY: ${{ secrets.MCP_KEY }}
|
||||||
run: |
|
run: |
|
||||||
NAME=mcp-publisher_1.2.3_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
|
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.2.3 using latest https for security and save it to a file named mcp-publisher.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.2.3/$NAME" -O
|
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fL "https://github.com/modelcontextprotocol/registry/releases/download/v1.4.0/$NAME" -O
|
||||||
|
|
||||||
# Verify the SHA256 checksum of the downloaded file
|
# Verify the SHA256 checksum of the downloaded file
|
||||||
sha256sum --ignore-missing -c ./checksums/registry_1.2.3_checksums.txt
|
sha256sum --ignore-missing -c ./checksums/registry_1.4.0_checksums.txt
|
||||||
|
|
||||||
# Extract the tarball
|
# Extract the tarball
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
@@ -31,8 +34,8 @@ jobs:
|
|||||||
# Install the MCP Publisher binary
|
# Install the MCP Publisher binary
|
||||||
install -m 0755 tmp/mcp-publisher .
|
install -m 0755 tmp/mcp-publisher .
|
||||||
|
|
||||||
# Login using GitHub OIDC
|
# Login using DNS
|
||||||
./mcp-publisher login github-oidc
|
./mcp-publisher login dns --domain svelte.dev --private-key "${MCP_KEY}"
|
||||||
|
|
||||||
# Publish to MCP Registry
|
# Publish to MCP Registry
|
||||||
./mcp-publisher publish
|
./mcp-publisher publish
|
||||||
|
|||||||
66
.github/workflows/release-svelte-skill.yml
vendored
Normal file
66
.github/workflows/release-svelte-skill.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Release Svelte Skills
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'tools/skills/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
detect-skills:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
if: github.repository == 'sveltejs/ai-tools'
|
||||||
|
name: Detect changed skills
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
skills: ${{ steps.find-skills.outputs.skills }}
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
|
||||||
|
- name: Find all skills
|
||||||
|
id: find-skills
|
||||||
|
run: |
|
||||||
|
skills=$(ls -d tools/skills/*/ | xargs -I {} basename {} | jq -R -s -c 'split("\n") | map(select(length > 0))')
|
||||||
|
echo "skills=$skills" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: detect-skills
|
||||||
|
if: needs.detect-skills.outputs.skills != '[]'
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
name: Release ${{ matrix.skill }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
skill: ${{ fromJson(needs.detect-skills.outputs.skills) }}
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 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 tools/skills
|
||||||
|
zip -r ${{ matrix.skill }}.zip ${{ matrix.skill }}/
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ matrix.skill }}-v${{ steps.version.outputs.version }}
|
||||||
|
name: ${{ matrix.skill }} v${{ steps.version.outputs.version }}
|
||||||
|
body: |
|
||||||
|
Automated release of the ${{ matrix.skill }} skill.
|
||||||
|
|
||||||
|
This release was triggered by changes to the `tools/skills/${{ matrix.skill }}/` directory.
|
||||||
|
files: tools/skills/${{ matrix.skill }}.zip
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
@@ -13,11 +13,11 @@ jobs:
|
|||||||
id-token: write # OpenID Connect token needed for provenance
|
id-token: write # OpenID Connect token needed for provenance
|
||||||
pull-requests: write # to create pull request (changesets/action)
|
pull-requests: write # to create pull request (changesets/action)
|
||||||
# prevents this action from running on forks
|
# prevents this action from running on forks
|
||||||
if: github.repository == 'sveltejs/mcp'
|
if: github.repository == 'sveltejs/ai-tools'
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
outputs:
|
outputs:
|
||||||
published: ${{ steps.changesets.outputs.published }}
|
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# pseudo-matrix for convenience, NEVER use more than a single combination
|
# pseudo-matrix for convenience, NEVER use more than a single combination
|
||||||
@@ -25,11 +25,11 @@ jobs:
|
|||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
with:
|
with:
|
||||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/setup-node@v5
|
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
package-manager-cache: false # pnpm is not installed yet
|
package-manager-cache: false # pnpm is not installed yet
|
||||||
@@ -39,10 +39,11 @@ 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)
|
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
|
echo installing pnpm version $PNPM_VER
|
||||||
npm i -g pnpm@$PNPM_VER
|
npm i -g pnpm@$PNPM_VER
|
||||||
- uses: actions/setup-node@v5
|
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
package-manager-cache: true # caches pnpm via packageManager field in package.json
|
package-manager-cache: true # caches pnpm via packageManager field in package.json
|
||||||
|
cache: 'pnpm'
|
||||||
- name: install
|
- name: install
|
||||||
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
|
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
|
||||||
- name: build
|
- name: build
|
||||||
@@ -51,7 +52,7 @@ jobs:
|
|||||||
- name: Create Release Pull Request or Publish to npm
|
- name: Create Release Pull Request or Publish to npm
|
||||||
id: changesets
|
id: changesets
|
||||||
# pinned for security, always review third party action code before updating
|
# pinned for security, always review third party action code before updating
|
||||||
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
|
uses: changesets/action@c48e67d110a68bc90ccf1098e9646092baacaa87 # v1.6.0
|
||||||
with:
|
with:
|
||||||
# This expects you to have a script called changeset:version version that calls changeset version and updated what it needs to be updated
|
# 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
|
version: pnpm changeset:version
|
||||||
@@ -63,7 +64,7 @@ jobs:
|
|||||||
|
|
||||||
publish-mcp:
|
publish-mcp:
|
||||||
needs: release
|
needs: release
|
||||||
if: needs.release.outputs.published == 'true'
|
if: contains(needs.release.outputs.publishedPackages, '"@sveltejs/mcp"')
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
uses: ./.github/workflows/publish-mcp.yml
|
uses: ./.github/workflows/publish-mcp.yml
|
||||||
|
secrets:
|
||||||
|
MCP_KEY: ${{ secrets.MCP_KEY }}
|
||||||
|
|||||||
116
.github/workflows/sync-docs-skills.yml
vendored
Normal file
116
.github/workflows/sync-docs-skills.yml
vendored
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
name: Sync Skills
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
actions: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-skills:
|
||||||
|
if: github.repository == 'sveltejs/ai-tools'
|
||||||
|
name: Sync skills from svelte.dev
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 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: Clone svelte.dev
|
||||||
|
run: git clone --depth 2 https://github.com/sveltejs/svelte.dev.git "${{ runner.temp }}/svelte.dev"
|
||||||
|
|
||||||
|
- name: Discover changed skill files
|
||||||
|
id: discover
|
||||||
|
env:
|
||||||
|
SVELTE_DEV_ROOT: ${{ runner.temp }}/svelte.dev
|
||||||
|
run: |
|
||||||
|
skill_files=$(git -C "$SVELTE_DEV_ROOT" diff --name-only --diff-filter=ACMR HEAD~1 HEAD | grep '^apps/svelte.dev/content/docs/.*\.md$' | xargs -I{} grep -l '^skill: *true' "$SVELTE_DEV_ROOT/{}" || true)
|
||||||
|
echo "skill_files=$skill_files" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Sync skills
|
||||||
|
if: steps.discover.outputs.skill_files != ''
|
||||||
|
env:
|
||||||
|
SVELTE_DEV_ROOT: ${{ runner.temp }}/svelte.dev
|
||||||
|
DOCS_PREFIX: apps/svelte.dev/content/docs/
|
||||||
|
run: |
|
||||||
|
for full_path in ${{ steps.discover.outputs.skill_files }}; do
|
||||||
|
file="${full_path#$SVELTE_DEV_ROOT/}"
|
||||||
|
name=$(grep '^name: ' "$full_path" | head -1 | sed 's/^name: *//')
|
||||||
|
repo="${file#$DOCS_PREFIX}"
|
||||||
|
repo="${repo#/}"
|
||||||
|
repo="${repo%%/*}"
|
||||||
|
|
||||||
|
output_dir="tools/skills/$name"
|
||||||
|
rm -rf "$output_dir"
|
||||||
|
mkdir -p "$output_dir"
|
||||||
|
|
||||||
|
pnpm resolve-references --file "$full_path" --repo "$repo" --output "$output_dir"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Sync plugins
|
||||||
|
if: steps.discover.outputs.skill_files != ''
|
||||||
|
run: |
|
||||||
|
pnpm sync-claude-plugin
|
||||||
|
pnpm sync-cursor-plugin
|
||||||
|
pnpm sync-opencode-plugin
|
||||||
|
pnpm generate-skill-docs
|
||||||
|
pnpm bump-plugin-versions
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: git-check
|
||||||
|
run: |
|
||||||
|
git diff --exit-code -- tools/skills/ plugins/ packages/opencode/ documentation/docs/ || 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 from svelte.dev'
|
||||||
|
branch: chore/sync-skills
|
||||||
|
delete-branch: true
|
||||||
|
title: 'chore: sync skills from svelte.dev'
|
||||||
|
body: |
|
||||||
|
## Summary
|
||||||
|
Automatically synced skill markdown from `sveltejs/svelte.dev` into `tools/skills/`.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
- Cloned `sveltejs/svelte.dev`
|
||||||
|
- Filtered markdown files with `skill: true` frontmatter
|
||||||
|
- Rebuilt synced skill folders with `scripts/resolve-references.ts`
|
||||||
|
- Synced `plugins/claude/svelte/` (skills, agents)
|
||||||
|
- Synced `plugins/cursor/svelte/` (skills, agents, rules)
|
||||||
|
- Synced `packages/opencode/` (skills, instructions)
|
||||||
|
- Updated documentation
|
||||||
|
|
||||||
|
## Generated by
|
||||||
|
GitHub Action: Sync Skills
|
||||||
|
labels: |
|
||||||
|
chore
|
||||||
|
automated
|
||||||
95
.github/workflows/sync-plugins.yml
vendored
Normal file
95
.github/workflows/sync-plugins.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
name: Sync Plugins
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'tools/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-plugins:
|
||||||
|
# prevents this action from running on forks
|
||||||
|
if: github.repository == 'sveltejs/ai-tools'
|
||||||
|
name: Sync Plugins from tools/
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 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 plugins
|
||||||
|
run: pnpm sync-plugins
|
||||||
|
|
||||||
|
- name: Generate skills documentation
|
||||||
|
run: pnpm generate-skill-docs
|
||||||
|
|
||||||
|
- name: Generate subagent documentation
|
||||||
|
run: pnpm generate-subagent-docs
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: git-check
|
||||||
|
run: |
|
||||||
|
git diff --exit-code \
|
||||||
|
plugins/claude/svelte/ \
|
||||||
|
plugins/cursor/svelte/ \
|
||||||
|
packages/opencode/skills/ \
|
||||||
|
packages/opencode/instructions/ \
|
||||||
|
packages/opencode/schema.json \
|
||||||
|
documentation/docs/ \
|
||||||
|
|| 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 plugins from tools/'
|
||||||
|
branch: chore/sync-plugins
|
||||||
|
delete-branch: true
|
||||||
|
title: 'chore: sync plugins from tools/'
|
||||||
|
body: |
|
||||||
|
## Summary
|
||||||
|
Automatically synced all plugins from the `tools/` source of truth.
|
||||||
|
|
||||||
|
This PR was triggered by changes to `tools/**`.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
- Synced `plugins/claude/svelte/` (skills, agents with `permissionMode`)
|
||||||
|
- Synced `plugins/cursor/svelte/` (skills, agents, rules)
|
||||||
|
- Synced `packages/opencode/` (skills, instructions, schema)
|
||||||
|
- Updated documentation
|
||||||
|
|
||||||
|
## Generated by
|
||||||
|
GitHub Action: Sync Plugins
|
||||||
|
labels: |
|
||||||
|
chore
|
||||||
|
automated
|
||||||
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@@ -13,17 +13,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
|
||||||
- name: Setup pnpm
|
- name: Setup pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
|
||||||
with:
|
|
||||||
version: 10.18.1
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '24'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -32,13 +30,9 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: pnpm run build
|
run: pnpm run build
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: file:test.db
|
|
||||||
VOYAGE_API_KEY: dummy-key
|
VOYAGE_API_KEY: dummy-key
|
||||||
DATABASE_TOKEN: dummy-key
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pnpm run test
|
run: pnpm run test
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: file:test.db
|
|
||||||
VOYAGE_API_KEY: dummy-key
|
VOYAGE_API_KEY: dummy-key
|
||||||
DATABASE_TOKEN: dummy-key
|
|
||||||
|
|||||||
78
.github/workflows/update-opencode-jsonschema.yml
vendored
Normal file
78
.github/workflows/update-opencode-jsonschema.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
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/ai-tools'
|
||||||
|
name: Update OpenCode JSON Schema
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 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
|
||||||
79
.github/workflows/update-prompt-docs.yml
vendored
Normal file
79
.github/workflows/update-prompt-docs.yml
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
name: Update Prompt Documentation
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'packages/mcp-server/src/mcp/handlers/prompts/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-docs:
|
||||||
|
# prevents this action from running on forks
|
||||||
|
if: github.repository == 'sveltejs/ai-tools'
|
||||||
|
name: Update Prompt Documentation
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 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 prompt documentation
|
||||||
|
run: pnpm generate-prompt-docs
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: git-check
|
||||||
|
run: |
|
||||||
|
git diff --exit-code documentation/docs/30-capabilities/30-prompts.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: 'docs: update prompts documentation'
|
||||||
|
branch: docs/update-prompt-docs
|
||||||
|
delete-branch: true
|
||||||
|
title: 'docs: update prompt documentation'
|
||||||
|
body: |
|
||||||
|
## Summary
|
||||||
|
Automatically generated documentation update for MCP prompts.
|
||||||
|
|
||||||
|
This PR was triggered by changes to the prompts folder in `packages/mcp-server/src/mcp/handlers/prompts/`.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
- Updated `documentation/docs/30-capabilities/30-prompts.md` with latest prompt definitions
|
||||||
|
|
||||||
|
## Generated by
|
||||||
|
GitHub Action: Update Prompt Documentation
|
||||||
|
labels: |
|
||||||
|
documentation
|
||||||
|
automated
|
||||||
@@ -11,4 +11,7 @@ bun.lockb
|
|||||||
/**/.svelte-kit/*
|
/**/.svelte-kit/*
|
||||||
|
|
||||||
# Claude Code
|
# Claude Code
|
||||||
.claude/
|
.claude/
|
||||||
|
.changeset/
|
||||||
|
|
||||||
|
/packages/opencode/schema.json
|
||||||
@@ -10,6 +10,12 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"parser": "svelte"
|
"parser": "svelte"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": "**/references/*.md",
|
||||||
|
"options": {
|
||||||
|
"embeddedLanguageFormatting": "off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
63
.vscode/mcp-snippets.code-snippets
vendored
63
.vscode/mcp-snippets.code-snippets
vendored
@@ -12,6 +12,7 @@
|
|||||||
"body": [
|
"body": [
|
||||||
"import type { SvelteMcp } from '../../index.js';",
|
"import type { SvelteMcp } from '../../index.js';",
|
||||||
"import * as v from 'valibot';",
|
"import * as v from 'valibot';",
|
||||||
|
"import { icons } from '../../icons/index.js';",
|
||||||
"",
|
"",
|
||||||
"export function ${1:function_name}(server: SvelteMcp) {",
|
"export function ${1:function_name}(server: SvelteMcp) {",
|
||||||
"\t$0",
|
"\t$0",
|
||||||
@@ -23,11 +24,71 @@
|
|||||||
"scope": "javascript,typescript",
|
"scope": "javascript,typescript",
|
||||||
"prefix": "!autofixer",
|
"prefix": "!autofixer",
|
||||||
"body": [
|
"body": [
|
||||||
"import type { Autofixer } from '.';",
|
"import type { Autofixer } from './index.js';",
|
||||||
"export const ${1:autofixer_name}: Autofixer = {",
|
"export const ${1:autofixer_name}: Autofixer = {",
|
||||||
"\t$0",
|
"\t$0",
|
||||||
"};",
|
"};",
|
||||||
],
|
],
|
||||||
"description": "Create a setup export for an autofixer",
|
"description": "Create a setup export for an autofixer",
|
||||||
},
|
},
|
||||||
|
"Prompt Generator": {
|
||||||
|
"scope": "javascript,typescript",
|
||||||
|
"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",
|
||||||
|
" * if needed (it will always be invoked manually so it's up to you to provide the arguments).",
|
||||||
|
" */",
|
||||||
|
"function ${1:prompt_name}() {",
|
||||||
|
"\treturn `$0`;",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * This function is used to generate the prompt to update the docs in the script `/scripts/update-docs-prompts.ts` it should use the default export",
|
||||||
|
" * function and pass in the arguments. Since it will be included in the documentation if it's an argument that the MCP will expose it should",
|
||||||
|
" * be in the format [NAME_OF_THE_ARGUMENT] to signal the user that it can substitute it.",
|
||||||
|
" * ",
|
||||||
|
" * The name NEEDS to be `generate_for_docs`.",
|
||||||
|
" */",
|
||||||
|
"export async function generate_for_docs() {",
|
||||||
|
"\treturn ${1:prompt_name}();",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * Human readable description of what the prompt does. It will be included in the documentation.",
|
||||||
|
" * ",
|
||||||
|
" * The name NEEDS to be `docs_description`.",
|
||||||
|
" */",
|
||||||
|
"export const docs_description = '';",
|
||||||
|
"",
|
||||||
|
"export function setup_${1:prompt_name}(server: SvelteMcp) {",
|
||||||
|
"\tserver.prompt(",
|
||||||
|
"\t\t{",
|
||||||
|
"\t\t\tname: '${1:prompt_name}',",
|
||||||
|
"\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 {",
|
||||||
|
"\t\t\t\tmessages: [",
|
||||||
|
"\t\t\t\t\t{",
|
||||||
|
"\t\t\t\t\t\trole: 'assistant',",
|
||||||
|
"\t\t\t\t\t\tcontent: {",
|
||||||
|
"\t\t\t\t\t\t\ttype: 'text',",
|
||||||
|
"\t\t\t\t\t\t\ttext: ${1:prompt_name}(),",
|
||||||
|
"\t\t\t\t\t\t},",
|
||||||
|
"\t\t\t\t\t},",
|
||||||
|
"\t\t\t\t],",
|
||||||
|
"\t\t\t};",
|
||||||
|
"\t\t},",
|
||||||
|
"\t);",
|
||||||
|
"}",
|
||||||
|
],
|
||||||
|
"description": "Create a setup export for a prompt generator",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ Located in `src/lib/server/analyze/`:
|
|||||||
|
|
||||||
Required environment variables:
|
Required environment variables:
|
||||||
|
|
||||||
- `DATABASE_URL`: SQLite database path (default: `file:test.db`)
|
|
||||||
- `VOYAGE_API_KEY`: API key for embeddings support (optional)
|
- `VOYAGE_API_KEY`: API key for embeddings support (optional)
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 [Svelte Contributors](https://github.com/sveltejs/ai-tools/graphs/contributors)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,3 +1 @@
|
|||||||
DATABASE_URL=file:test.db
|
|
||||||
DATABASE_TOKEN=needs_to_be_set_but_it_can_be_anything
|
|
||||||
VOYAGE_API_KEY=your_actual_api_key_here
|
VOYAGE_API_KEY=your_actual_api_key_here
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { defineConfig } from 'drizzle-kit';
|
|
||||||
|
|
||||||
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
|
||||||
if (!process.env.DATABASE_TOKEN) throw new Error('DATABASE_TOKEN is not set');
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
schema: './src/lib/server/db/schema.ts',
|
|
||||||
dialect: 'turso',
|
|
||||||
dbCredentials: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_TOKEN },
|
|
||||||
verbose: true,
|
|
||||||
strict: true,
|
|
||||||
});
|
|
||||||
@@ -23,10 +23,6 @@
|
|||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"test": "npm run test:unit -- --run",
|
"test": "npm run test:unit -- --run",
|
||||||
"test:watch": "npm run test:unit -- --watch",
|
"test:watch": "npm run test:unit -- --watch",
|
||||||
"db:push": "drizzle-kit push",
|
|
||||||
"db:generate": "drizzle-kit generate",
|
|
||||||
"db:migrate": "drizzle-kit migrate",
|
|
||||||
"db:studio": "drizzle-kit studio",
|
|
||||||
"inspect": "pnpm mcp-inspector"
|
"inspect": "pnpm mcp-inspector"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -37,34 +33,31 @@
|
|||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.3.2",
|
"@eslint/compat": "catalog:lint",
|
||||||
"@eslint/js": "^9.36.0",
|
"@eslint/js": "catalog:lint",
|
||||||
"@libsql/client": "^0.15.0",
|
"@modelcontextprotocol/inspector": "catalog:ai",
|
||||||
"@modelcontextprotocol/inspector": "^0.17.0",
|
"@sveltejs/adapter-vercel": "catalog:svelte",
|
||||||
"@sveltejs/adapter-vercel": "^5.6.3",
|
"@sveltejs/kit": "catalog:svelte",
|
||||||
"@sveltejs/kit": "^2.22.0",
|
"@sveltejs/vite-plugin-svelte": "catalog:svelte",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
"@types/node": "catalog:tooling",
|
||||||
"@types/node": "^24.3.1",
|
"@typescript-eslint/parser": "catalog:lint",
|
||||||
"@typescript-eslint/parser": "^8.44.0",
|
"eslint-config-prettier": "catalog:lint",
|
||||||
"drizzle-kit": "^0.31.0",
|
"eslint-plugin-svelte": "catalog:lint",
|
||||||
"drizzle-orm": "^0.44.0",
|
"globals": "catalog:lint",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"prettier": "catalog:lint",
|
||||||
"eslint-plugin-svelte": "^3.12.3",
|
"prettier-plugin-svelte": "catalog:lint",
|
||||||
"globals": "^16.0.0",
|
"svelte": "catalog:svelte",
|
||||||
"prettier": "^3.4.2",
|
"svelte-check": "catalog:svelte",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"svelte-eslint-parser": "catalog:lint",
|
||||||
"svelte": "^5.0.0",
|
"typescript": "catalog:tooling",
|
||||||
"svelte-check": "^4.0.0",
|
"vite": "catalog:tooling",
|
||||||
"svelte-eslint-parser": "^1.3.2",
|
"vite-plugin-devtools-json": "catalog:tooling",
|
||||||
"typescript": "^5.0.0",
|
"vitest": "catalog:tooling"
|
||||||
"vite": "^7.0.4",
|
|
||||||
"vite-plugin-devtools-json": "^1.0.0",
|
|
||||||
"vitest": "^3.2.3"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/mcp-schema": "workspace:^",
|
|
||||||
"@sveltejs/mcp-server": "workspace:^",
|
"@sveltejs/mcp-server": "workspace:^",
|
||||||
"@tmcp/transport-http": "^0.6.3",
|
"@tmcp/transport-http": "catalog:tmcp",
|
||||||
"tmcp": "^1.14.0"
|
"@vercel/analytics": "catalog:tooling",
|
||||||
|
"tmcp": "catalog:tmcp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { dev } from '$app/environment';
|
||||||
import { http_transport } from '$lib/mcp/index.js';
|
import { http_transport } from '$lib/mcp/index.js';
|
||||||
import { db } from '$lib/server/db/index.js';
|
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
import { track } from '@vercel/analytics/server';
|
||||||
|
|
||||||
export async function handle({ event, resolve }) {
|
export async function handle({ event, resolve }) {
|
||||||
if (event.request.method === 'GET') {
|
if (event.request.method === 'GET') {
|
||||||
@@ -15,21 +16,12 @@ export async function handle({ event, resolve }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const mcp_response = await http_transport.respond(event.request, {
|
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);
|
return mcp_response ?? resolve(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,10 @@ import { HttpTransport } from '@tmcp/transport-http';
|
|||||||
|
|
||||||
export const http_transport = new HttpTransport(server, {
|
export const http_transport = new HttpTransport(server, {
|
||||||
cors: true,
|
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,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
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');
|
|
||||||
|
|
||||||
const client = createClient({
|
|
||||||
url: DATABASE_URL,
|
|
||||||
authToken: DATABASE_TOKEN,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const db = drizzle(client, { schema, logger: true });
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
// we need to re-export from here to allow for the drizzle config to pick them up for migrations
|
|
||||||
export * from '@sveltejs/mcp-schema/schema';
|
|
||||||
BIN
apps/mcp-remote/static/logo.png
Normal file
BIN
apps/mcp-remote/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
1
apps/mcp-remote/static/logo.svg
Normal file
1
apps/mcp-remote/static/logo.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -2,43 +2,11 @@
|
|||||||
title: Overview
|
title: Overview
|
||||||
---
|
---
|
||||||
|
|
||||||
The Svelte MCP ([Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)) server can help your LLM or agent of choice write better Svelte code. It works by providing documentation relevant to the task at hand, and statically analysing generated code so that it can suggest fixes and best practices.
|
The following pages will help you set up and use the AI tools officially maintained by the Svelte team.
|
||||||
|
|
||||||
## Setup
|
There are four tools, designed to help your agent write correct, robust Svelte code. They are designed to work together, but each can be used individually:
|
||||||
|
|
||||||
The setup varies based on the version of the MCP you prefer — remote or local — and your chosen MCP client (e.g. Claude Code, Codex CLI or GitHub Copilot):
|
- [Instructions](instructions): small prompt always injected into your session to make your agent more aware of the available tools
|
||||||
|
- [MCP Server](mcp): with tools, prompts and resources to give your agent more context, by pulling directly from the official Svelte documentation and using static analysis to correct common generative AI pitfalls
|
||||||
- [local setup](local-setup) using `@sveltejs/mcp`
|
- [Skills](skills): lazy-loaded descriptions that teach your agent Svelte best practices, and how to use the [`@sveltejs/mcp` cli](cli)
|
||||||
- [remote setup](remote-setup) using `https://mcp.svelte.dev/mcp`
|
- [Subagents](subagent): focused agents that can be invoked in parallel to execute atomic operations in a separate context window
|
||||||
|
|
||||||
## 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). This will tell the LLM which tools are available and when it's appropriate to use them.
|
|
||||||
|
|
||||||
```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:
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|||||||
23
documentation/docs/20-instructions/.generated/agents.md
Normal file
23
documentation/docs/20-instructions/.generated/agents.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
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.
|
||||||
13
documentation/docs/20-instructions/10-instructions.md
Normal file
13
documentation/docs/20-instructions/10-instructions.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: AGENTS.md
|
||||||
|
---
|
||||||
|
|
||||||
|
To get the most out of the [MCP server](mcp) and [skills](skills) 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) or [`GEMINI.md`](https://geminicli.com/docs/cli/gemini-md/), if using Claude Code or Gemini). This will tell your agent which tools are available and when it is appropriate to use them.
|
||||||
|
|
||||||
|
> [!NOTE] This is already setup for you when using `npx sv add mcp`
|
||||||
|
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
````markdown
|
||||||
|
@include .generated/agents.md
|
||||||
|
````
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
3
documentation/docs/20-instructions/index.md
Normal file
3
documentation/docs/20-instructions/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Instructions
|
||||||
|
---
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Setup
|
|
||||||
---
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Capabilities
|
|
||||||
---
|
|
||||||
213
documentation/docs/30-mcp/.generated/prompts.md
Normal file
213
documentation/docs/30-mcp/.generated/prompts.md
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
## 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>
|
||||||
|
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
````markdown
|
||||||
|
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: use title and path to estimate use case, path: ai/overview
|
||||||
|
- title: Local setup, use_cases: use title and path to estimate use case, path: ai/local-setup
|
||||||
|
- title: Remote setup, use_cases: use title and path to estimate use case, path: ai/remote-setup
|
||||||
|
- title: Tools, use_cases: use title and path to estimate use case, path: ai/tools
|
||||||
|
- title: Resources, use_cases: use title and path to estimate use case, path: ai/resources
|
||||||
|
- title: Prompts, use_cases: use title and path to estimate use case, path: ai/prompts
|
||||||
|
- title: Overview, use_cases: use title and path to estimate use case, path: ai/plugin
|
||||||
|
- title: Subagent, use_cases: use title and path to estimate use case, path: ai/subagent
|
||||||
|
- title: Overview, use_cases: use title and path to estimate use case, path: ai/opencode-plugin
|
||||||
|
- title: Subagent, use_cases: use title and path to estimate use case, path: ai/opencode-subagent
|
||||||
|
- title: Overview, use_cases: use title and path to estimate use case, path: ai/skills
|
||||||
|
- 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: better-auth, use_cases: use title and path to estimate use case, path: cli/better-auth
|
||||||
|
- 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: sv-utils, use_cases: use title and path to estimate use case, path: cli/sv-utils
|
||||||
|
- 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: 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: Best practices, use_cases: use title and path to estimate use case, path: svelte/best-practices
|
||||||
|
- 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.
|
||||||
|
````
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
</details>
|
||||||
16
documentation/docs/30-mcp/10-mcp.md
Normal file
16
documentation/docs/30-mcp/10-mcp.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
title: Overview
|
||||||
|
---
|
||||||
|
|
||||||
|
The Svelte MCP ([Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro)) server can help your agent write better Svelte code. It works by providing relevant documentation, and statically analysing generated code so that it can suggest fixes and best practices.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
The setup varies based on the version of the MCP you prefer — remote or local — and your chosen MCP client (e.g. Claude Code, Codex CLI or GitHub Copilot):
|
||||||
|
|
||||||
|
- [local setup](local-setup) using `@sveltejs/mcp`
|
||||||
|
- [remote setup](remote-setup) using `https://mcp.svelte.dev/mcp`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -37,7 +37,7 @@ In the Settings > Developer section, click on Edit Config. It will open the fold
|
|||||||
|
|
||||||
## Codex CLI
|
## Codex CLI
|
||||||
|
|
||||||
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
|
You can automatically configure the MCP server using the [Codex plugin](codex-plugin) (recommended). If you prefer to configure the MCP server manually, add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[mcp_servers.svelte]
|
[mcp_servers.svelte]
|
||||||
@@ -45,19 +45,45 @@ command = "npx"
|
|||||||
args = ["-y", "@sveltejs/mcp"]
|
args = ["-y", "@sveltejs/mcp"]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Gemini CLI
|
## Copilot CLI
|
||||||
|
|
||||||
To include the local MCP version in Gemini CLI, simply run the following command:
|
You can automatically configure the MCP server using the [Copilot plugin](copilot-plugin) (recommended). If you prefer to configure the MCP server manually, use the Copilot CLI to interactively add the MCP server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gemini mcp add -t stdio -s [scope] svelte npx -y @sveltejs/mcp
|
/mcp add
|
||||||
```
|
```
|
||||||
|
|
||||||
The `[scope]` must be `user`, `project` or `local`.
|
Alternatively, create or edit `~/.copilot/mcp-config.json` and add the following configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"svelte": {
|
||||||
|
"command": "npx",
|
||||||
|
"args": ["-y", "@sveltejs/mcp"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Antigravity CLI
|
||||||
|
|
||||||
|
To use the local MCP version in Antigravity CLI, create or edit `~/.gemini/config/mcp_config.json` and add the following configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"svelte": {
|
||||||
|
"command": "npx",
|
||||||
|
"args": ["-y", "@sveltejs/mcp"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## OpenCode
|
## OpenCode
|
||||||
|
|
||||||
Run the command:
|
You can automatically configure the MCP server using the [OpenCode plugin](opencode-plugin) (recommended). If you prefer to configure the MCP server manually, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
opencode mcp add
|
opencode mcp add
|
||||||
@@ -91,6 +117,8 @@ opencode mcp add
|
|||||||
|
|
||||||
## Cursor
|
## Cursor
|
||||||
|
|
||||||
|
You can automatically configure the MCP server using the [Cursor plugin](cursor-plugin) (recommended). If you prefer to configure the MCP server manually you can:
|
||||||
|
|
||||||
- Open the command palette
|
- Open the command palette
|
||||||
- Select "View: Open MCP Settings"
|
- Select "View: Open MCP Settings"
|
||||||
- Click on "Add custom MCP"
|
- Click on "Add custom MCP"
|
||||||
@@ -110,6 +138,12 @@ It will open a file with your MCP servers where you can add the following config
|
|||||||
|
|
||||||
## Zed
|
## Zed
|
||||||
|
|
||||||
|
Install the [Svelte MCP Server extension](https://zed.dev/extensions/svelte-mcp).
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
<summary>Configure Manually</summary>
|
||||||
|
|
||||||
- Open the command palette
|
- Open the command palette
|
||||||
- Search and select "agent:open settings"
|
- Search and select "agent:open settings"
|
||||||
- In settings panel look for `Model Context Protocol (MCP) Servers`
|
- In settings panel look for `Model Context Protocol (MCP) Servers`
|
||||||
@@ -127,6 +161,8 @@ It will open a popup with MCP server config where you can add the following conf
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Other clients
|
## 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.
|
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.
|
||||||
@@ -16,6 +16,8 @@ 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`.
|
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](claude-plugin) that will give you both the remote server and useful [skills](skills).
|
||||||
|
|
||||||
## Claude Desktop
|
## Claude Desktop
|
||||||
|
|
||||||
- Open Settings > Connectors
|
- Open Settings > Connectors
|
||||||
@@ -26,7 +28,7 @@ You can choose your preferred `scope` (it must be `user`, `project` or `local`)
|
|||||||
|
|
||||||
## Codex CLI
|
## Codex CLI
|
||||||
|
|
||||||
Add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
|
You can automatically configure the MCP server using the [Codex plugin](codex-plugin) (recommended). If you prefer to configure the MCP server manually, add the following to your `config.toml` (which defaults to `~/.codex/config.toml`, but refer to [the configuration documentation](https://github.com/openai/codex/blob/main/docs/config.md) for more advanced setups):
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
experimental_use_rmcp_client = true
|
experimental_use_rmcp_client = true
|
||||||
@@ -34,19 +36,43 @@ experimental_use_rmcp_client = true
|
|||||||
url = "https://mcp.svelte.dev/mcp"
|
url = "https://mcp.svelte.dev/mcp"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Gemini CLI
|
## Copilot CLI
|
||||||
|
|
||||||
To use the remote MCP server with Gemini CLI, simply run the following command:
|
You can automatically configure the MCP server using the [Copilot plugin](copilot-plugin) (recommended). If you prefer to configure the MCP server manually, use the Copilot CLI to interactively add the MCP server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gemini mcp add -t http -s [scope] svelte https://mcp.svelte.dev/mcp
|
/mcp add
|
||||||
```
|
```
|
||||||
|
|
||||||
The `[scope]` must be `user`, `project` or `local`.
|
Alternatively, create or edit `~/.copilot/mcp-config.json` and add the following configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"svelte": {
|
||||||
|
"url": "https://mcp.svelte.dev/mcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Antigravity CLI
|
||||||
|
|
||||||
|
To use the remote MCP version in Antigravity CLI, create or edit `~/.gemini/config/mcp_config.json` and add the following configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"svelte": {
|
||||||
|
"url": "https://mcp.svelte.dev/mcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## OpenCode
|
## OpenCode
|
||||||
|
|
||||||
Run the command:
|
You can automatically configure the MCP server using the [OpenCode plugin](opencode-plugin) (recommended). If you prefer to configure the MCP server manually, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
opencode mcp add
|
opencode mcp add
|
||||||
@@ -80,6 +106,8 @@ opencode mcp add
|
|||||||
|
|
||||||
## Cursor
|
## Cursor
|
||||||
|
|
||||||
|
You can automatically configure the MCP server using the [Cursor plugin](cursor-plugin) (recommended). If you prefer to configure the MCP server manually you can:
|
||||||
|
|
||||||
- Open the command palette
|
- Open the command palette
|
||||||
- Select "View: Open MCP Settings"
|
- Select "View: Open MCP Settings"
|
||||||
- Click on "Add custom MCP"
|
- Click on "Add custom MCP"
|
||||||
@@ -96,6 +124,27 @@ 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
|
## 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.
|
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.
|
||||||
@@ -4,6 +4,4 @@ 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.
|
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.
|
||||||
|
|
||||||
## svelte-task
|
@include .generated/prompts.md
|
||||||
|
|
||||||
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.
|
|
||||||
78
documentation/docs/30-mcp/70-cli.md
Normal file
78
documentation/docs/30-mcp/70-cli.md
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
title: CLI
|
||||||
|
---
|
||||||
|
|
||||||
|
The `@sveltejs/mcp` npm package normally launches the local `stdio` MCP server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
If you invoke it with a subcommand, it behaves like a regular CLI and prints the result directly in your terminal instead. This is useful for agents, scripts and quick manual checks.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp <command> [options]
|
||||||
|
```
|
||||||
|
|
||||||
|
Available commands:
|
||||||
|
|
||||||
|
- `list-sections`
|
||||||
|
- `get-documentation <sections>`
|
||||||
|
- `svelte-autofixer <code_or_path>`
|
||||||
|
|
||||||
|
You can learn more about the commands with
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp --help
|
||||||
|
npx -y @sveltejs/mcp <command> --help
|
||||||
|
npx -y @sveltejs/mcp --version
|
||||||
|
```
|
||||||
|
|
||||||
|
## `list-sections`
|
||||||
|
|
||||||
|
Lists all available Svelte and SvelteKit documentation sections.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp list-sections
|
||||||
|
```
|
||||||
|
|
||||||
|
The output is a structured text list of sections, including each section's title, `use_cases`, and documentation path. This is the same catalog the MCP tool uses before calling `get-documentation`.
|
||||||
|
|
||||||
|
## `get-documentation`
|
||||||
|
|
||||||
|
Fetches the full documentation for one or more sections.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp get-documentation 'svelte/$state'
|
||||||
|
# or
|
||||||
|
npx -y @sveltejs/mcp get-documentation 'svelte/$state,svelte/await-expressions'
|
||||||
|
```
|
||||||
|
|
||||||
|
Each section can be matched by title or by documentation path. If a section cannot be found, the CLI returns an error plus similar matches when available.
|
||||||
|
|
||||||
|
## `svelte-autofixer`
|
||||||
|
|
||||||
|
Runs the Svelte autofixer against either inline code or a file path:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx -y @sveltejs/mcp svelte-autofixer 'src/routes/+page.svelte'
|
||||||
|
```
|
||||||
|
|
||||||
|
If the argument is an existing path, the CLI reads the file automatically. Otherwise it treats the argument as raw Svelte code.
|
||||||
|
|
||||||
|
Because most shells expand `$`, inline code should be quoted or escaped correctly. In practice, passing a file path is usually easier than passing source directly.
|
||||||
|
|
||||||
|
Available options:
|
||||||
|
|
||||||
|
- `--svelte-version <4|5>` - choose which Svelte version to validate against (defaults to `5`)
|
||||||
|
- `--async` - enable async Svelte analysis for Svelte 5 projects
|
||||||
|
|
||||||
|
The command prints an object with:
|
||||||
|
|
||||||
|
- `issues`
|
||||||
|
- `suggestions`
|
||||||
|
- `require_another_tool_call_after_fixing`
|
||||||
|
|
||||||
|
This makes it easy to use in an agentic loop: run the autofixer, apply fixes, then run it again until it reports no remaining issues or suggestions.
|
||||||
3
documentation/docs/30-mcp/index.md
Normal file
3
documentation/docs/30-mcp/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: MCP server
|
||||||
|
---
|
||||||
263
documentation/docs/40-skills/.generated/skills.md
Normal file
263
documentation/docs/40-skills/.generated/skills.md
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
## `svelte-code-writer`
|
||||||
|
|
||||||
|
CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating, editing or analyzing any Svelte component (.svelte) or Svelte module (.svelte.ts/.svelte.js). If possible, this skill should be executed within the svelte-file-editor agent for optimal results.
|
||||||
|
|
||||||
|
<a href="https://github.com/sveltejs/ai-tools/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>
|
||||||
|
|
||||||
|
## `svelte-core-bestpractices`
|
||||||
|
|
||||||
|
Guidance on writing fast, robust, modern Svelte code. Load this skill whenever in a Svelte project and asked to write/edit or analyze a Svelte component or module. Covers reactivity, event handling, styling, integration with libraries and more.
|
||||||
|
|
||||||
|
<a href="https://github.com/sveltejs/ai-tools/releases?q=svelte-core-bestpractices" target="_blank" rel="noopener noreferrer">Open Releases page</a>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>View skill content</summary>
|
||||||
|
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
````markdown
|
||||||
|
## `$state`
|
||||||
|
|
||||||
|
Only use the `$state` rune for variables that should be _reactive_ — in other words, variables that cause an `$effect`, `$derived` or template expression to update. Everything else can be a normal variable.
|
||||||
|
|
||||||
|
Objects and arrays (`$state({...})` or `$state([...])`) are made deeply reactive, meaning mutation will trigger updates. This has a trade-off: in exchange for fine-grained reactivity, the objects must be proxied, which has performance overhead. In cases where you're dealing with large objects that are only ever reassigned (rather than mutated), use `$state.raw` instead. This is often the case with API responses, for example.
|
||||||
|
|
||||||
|
## `$derived`
|
||||||
|
|
||||||
|
To compute something from state, use `$derived` rather than `$effect`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// do this
|
||||||
|
let square = $derived(num * num);
|
||||||
|
|
||||||
|
// don't do this
|
||||||
|
let square;
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
square = num * num;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE] `$derived` is given an expression, _not_ a function. If you need to use a function (because the expression is complex, for example) use `$derived.by`.
|
||||||
|
|
||||||
|
Deriveds are writable — you can assign to them, just like `$state`, except that they will re-evaluate when their expression changes.
|
||||||
|
|
||||||
|
If the derived expression is an object or array, it will be returned as-is — it is _not_ made deeply reactive. You can, however, use `$state` inside `$derived.by` in the rare cases that you need this.
|
||||||
|
|
||||||
|
## `$effect`
|
||||||
|
|
||||||
|
Effects are an escape hatch and should mostly be avoided. In particular, avoid updating state inside effects.
|
||||||
|
|
||||||
|
- If you need to sync state to an external library such as D3, it is often neater to use [`{@attach ...}`](references/@attach.md)
|
||||||
|
- If you need to run some code in response to user interaction, put the code directly in an event handler or use a [function binding](references/bind.md) as appropriate
|
||||||
|
- If you need to log values for debugging purposes, use [`$inspect`](references/$inspect.md)
|
||||||
|
- If you need to observe something external to Svelte, use [`createSubscriber`](references/svelte-reactivity.md)
|
||||||
|
|
||||||
|
Never wrap the contents of an effect in `if (browser) {...}` or similar — effects do not run on the server.
|
||||||
|
|
||||||
|
## `$props`
|
||||||
|
|
||||||
|
Treat props as though they will change. For example, values that depend on props should usually use `$derived`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// @errors: 2451
|
||||||
|
let { type } = $props();
|
||||||
|
|
||||||
|
// do this
|
||||||
|
let color = $derived(type === 'danger' ? 'red' : 'green');
|
||||||
|
|
||||||
|
// don't do this — `color` will not update if `type` changes
|
||||||
|
let color = type === 'danger' ? 'red' : 'green';
|
||||||
|
```
|
||||||
|
|
||||||
|
## `$inspect.trace`
|
||||||
|
|
||||||
|
`$inspect.trace` is a debugging tool for reactivity. If something is not updating properly or running more than it should you can add `$inspect.trace(label)` as the first line of an `$effect` or `$derived.by` (or any function they call) to trace their dependencies and discover which one triggered an update.
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
Any element attribute starting with `on` is treated as an event listener:
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
<button onclick={() => {...}}>click me</button>
|
||||||
|
|
||||||
|
<!-- attribute shorthand also works -->
|
||||||
|
<button {onclick}>...</button>
|
||||||
|
|
||||||
|
<!-- so do spread attributes -->
|
||||||
|
<button {...props}>...</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need to attach listeners to `window` or `document` you can use `<svelte:window>` and `<svelte:document>`:
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
<svelte:window onkeydown={...} />
|
||||||
|
<svelte:document onvisibilitychange={...} />
|
||||||
|
```
|
||||||
|
|
||||||
|
Avoid using `onMount` or `$effect` for this.
|
||||||
|
|
||||||
|
## Snippets
|
||||||
|
|
||||||
|
[Snippets](references/snippet.md) are a way to define reusable chunks of markup that can be instantiated with the [`{@render ...}`](references/@render.md) tag, or passed to components as props. They must be declared within the template.
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
{#snippet greeting(name)}
|
||||||
|
<p>hello {name}!</p>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
{@render greeting('world')}
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!NOTE] Snippets declared at the top level of a component (i.e. not inside elements or blocks) can be referenced inside `<script>`. A snippet that doesn't reference component state is also available in a `<script module>`, in which case it can be exported for use by other components.
|
||||||
|
|
||||||
|
## Each blocks
|
||||||
|
|
||||||
|
Prefer to use [keyed each blocks](references/each.md) — this improves performance by allowing Svelte to surgically insert or remove items rather than updating the DOM belonging to existing items.
|
||||||
|
|
||||||
|
> [!NOTE] The key _must_ uniquely identify the object. Do not use the index as a key.
|
||||||
|
|
||||||
|
Avoid destructuring if you need to mutate the item (with something like `bind:value={item.count}`, for example).
|
||||||
|
|
||||||
|
## Using JavaScript variables in CSS
|
||||||
|
|
||||||
|
If you have a JS variable that you want to use inside CSS you can set a CSS custom property with the `style:` directive.
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
<div style:--columns={columns}>...</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then reference `var(--columns)` inside the component's `<style>`.
|
||||||
|
|
||||||
|
## Styling child components
|
||||||
|
|
||||||
|
The CSS in a component's `<style>` is scoped to that component. If a parent component needs to control the child's styles, the preferred way is to use CSS custom properties:
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
<!-- Parent.svelte -->
|
||||||
|
<Child --color="red" />
|
||||||
|
|
||||||
|
<!-- Child.svelte -->
|
||||||
|
<h1>Hello</h1>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
h1 {
|
||||||
|
color: var(--color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
```
|
||||||
|
|
||||||
|
If this is impossible (for example, the child component comes from a library) you can use `:global` to override styles:
|
||||||
|
|
||||||
|
```svelte
|
||||||
|
<div>
|
||||||
|
<Child />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div :global {
|
||||||
|
h1 {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
Consider using context instead of declaring state in a shared module. This will scope the state to the part of the app that needs it, and eliminate the possibility of it leaking between users when server-side rendering.
|
||||||
|
|
||||||
|
Use `createContext` rather than `setContext` and `getContext`, as it provides type safety.
|
||||||
|
|
||||||
|
## Async Svelte
|
||||||
|
|
||||||
|
If using version 5.36 or higher, you can use [await expressions](references/await-expressions.md) and [hydratable](references/hydratable.md) to use promises directly inside components. Note that these require the `experimental.async` option to be enabled in `svelte.config.js` as they are not yet considered fully stable.
|
||||||
|
|
||||||
|
## Avoid legacy features
|
||||||
|
|
||||||
|
Always use runes mode for new code, and avoid features that have more modern replacements:
|
||||||
|
|
||||||
|
- use `$state` instead of implicit reactivity (e.g. `let count = 0; count += 1`)
|
||||||
|
- use `$derived` and `$effect` instead of `$:` assignments and statements (but only use effects when there is no better solution)
|
||||||
|
- use `$props` instead of `export let`, `$$props` and `$$restProps`
|
||||||
|
- use `onclick={...}` instead of `on:click={...}`
|
||||||
|
- use `{#snippet ...}` and `{@render ...}` instead of `<slot>` and `$$slots` and `<svelte:fragment>`
|
||||||
|
- use `<DynamicComponent>` instead of `<svelte:component this={DynamicComponent}>`
|
||||||
|
- use `import Self from './ThisComponent.svelte'` and `<Self>` instead of `<svelte:self>`
|
||||||
|
- use classes with `$state` fields to share reactivity between components, instead of using stores
|
||||||
|
- use `{@attach ...}` instead of `use:action`
|
||||||
|
- use clsx-style arrays and objects in `class` attributes, instead of the `class:` directive
|
||||||
|
````
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
</details>
|
||||||
11
documentation/docs/40-skills/10-skills.md
Normal file
11
documentation/docs/40-skills/10-skills.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: Overview
|
||||||
|
---
|
||||||
|
|
||||||
|
This is the list of available skills provided by Svelte. Skills are sets of instructions that AI agents can load on-demand to help with specific tasks.
|
||||||
|
|
||||||
|
Skills are available in the Claude Code plugin, the Codex CLI plugin, the GitHub Copilot CLI plugin, and the OpenCode plugin (`@sveltejs/opencode`). They can also be manually installed in your `.claude/skills`, `.copilot/skills`, or `.opencode/skills` folder.
|
||||||
|
|
||||||
|
You can download the latest skills from the [releases page](https://github.com/sveltejs/ai-tools/releases) of the repo, or find them in the [`tools/skills`](https://github.com/sveltejs/ai-tools/tree/main/tools/skills) folder.
|
||||||
|
|
||||||
|
@include .generated/skills.md
|
||||||
3
documentation/docs/40-skills/index.md
Normal file
3
documentation/docs/40-skills/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Skills
|
||||||
|
---
|
||||||
67
documentation/docs/50-subagents/.generated/subagent.md
Normal file
67
documentation/docs/50-subagents/.generated/subagent.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
name: svelte-file-editor
|
||||||
|
description: Specialized Svelte 5 code editor. MUST BE USED PROACTIVELY when creating, editing, or reviewing any .svelte file or .svelte.ts/.svelte.js module and MUST use the tools from the MCP server or the `svelte-file-editor` skill if they are available. Fetches relevant documentation and validates code using the Svelte MCP server tools.
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a Svelte 5 expert responsible for writing, editing, and validating Svelte components and modules. You have access to the Svelte MCP server which provides documentation and code analysis tools. Always use the tools from the svelte MCP server to fetch documentation with `get_documentation` and validating the code with `svelte_autofixer`. If the autofixer returns any issue or suggestions try to solve them.
|
||||||
|
|
||||||
|
If the MCP tools are not available you can use the `svelte-code-writer` skill to learn how to use the `@sveltejs/mcp` cli to access the same tools.
|
||||||
|
|
||||||
|
If the skill is not available you can run `npx @sveltejs/mcp@latest -y --help` to learn how to use it.
|
||||||
|
|
||||||
|
## Available MCP Tools
|
||||||
|
|
||||||
|
### 1. list-sections
|
||||||
|
|
||||||
|
Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths. Use this first to discover what documentation is available.
|
||||||
|
|
||||||
|
### 2. get-documentation
|
||||||
|
|
||||||
|
Retrieves full documentation for specified sections. Accepts a single section name or an array of section names. Use after `list-sections` to fetch relevant docs for the task at hand.
|
||||||
|
|
||||||
|
**Example sections:** `$state`, `$derived`, `$effect`, `$props`, `$bindable`, `snippets`, `routing`, `load functions`
|
||||||
|
|
||||||
|
### 3. svelte-autofixer
|
||||||
|
|
||||||
|
Analyzes Svelte code and returns suggestions to fix issues. Pass the component code directly to this tool. It will detect common mistakes like:
|
||||||
|
|
||||||
|
- Using `$effect` instead of `$derived` for computations
|
||||||
|
- Missing cleanup in effects
|
||||||
|
- Svelte 4 syntax (`on:click`, `export let`, `<slot>`)
|
||||||
|
- Missing keys in `{#each}` blocks
|
||||||
|
- And more
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
When invoked to work on a Svelte file:
|
||||||
|
|
||||||
|
### 1. Gather Context (if needed)
|
||||||
|
|
||||||
|
If you're uncertain about Svelte 5 syntax or patterns, use the MCP tools:
|
||||||
|
|
||||||
|
1. Call `list-sections` to see available documentation
|
||||||
|
2. Call `get-documentation` with relevant section names
|
||||||
|
|
||||||
|
### 2. Read the Target File
|
||||||
|
|
||||||
|
Read the file to understand the current implementation.
|
||||||
|
|
||||||
|
### 3. Make Changes
|
||||||
|
|
||||||
|
Apply edits following Svelte 5 best practices:
|
||||||
|
|
||||||
|
### 4. Validate Changes
|
||||||
|
|
||||||
|
After editing, ALWAYS call `svelte-autofixer` with the updated code to check for issues.
|
||||||
|
|
||||||
|
### 5. Fix Any Issues
|
||||||
|
|
||||||
|
If the autofixer reports problems, fix them and re-validate until no issues remain.
|
||||||
|
|
||||||
|
## Output Format
|
||||||
|
|
||||||
|
After completing your work, provide:
|
||||||
|
|
||||||
|
1. Summary of changes made
|
||||||
|
2. Any issues found and fixed by the autofixer
|
||||||
|
3. Recommendations for further improvements (if any)
|
||||||
20
documentation/docs/50-subagents/10-subagent.md
Normal file
20
documentation/docs/50-subagents/10-subagent.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: Overview
|
||||||
|
---
|
||||||
|
|
||||||
|
Since creating, editing or analyzing a Svelte file is an atomic operation we recommend creating a subagent that your main agent can invoke whenever it needs to interact with a Svelte component. Subagents use a separate context window, allowing them to fetch documentation, iterate with [`svelte-autofixer`](tools#svelte-autofixer) and write to the filesystem without wasting context in the main agent.
|
||||||
|
|
||||||
|
Delegation should happen automatically when appropriate, but you can also explicitly request the subagent be used for Svelte-related tasks.
|
||||||
|
|
||||||
|
You can write your own or take inspiration from the one available in the [`sveltejs/ai-tools`](https://github.com/sveltejs/ai-tools/tree/main/tools/agents) repository: a specialized subagent called `svelte-file-editor` designed for creating, editing, and reviewing Svelte files.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>View subagent definition</summary>
|
||||||
|
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
````markdown
|
||||||
|
@include .generated/subagent.md
|
||||||
|
````
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
</details>
|
||||||
3
documentation/docs/50-subagents/index.md
Normal file
3
documentation/docs/50-subagents/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Subagents
|
||||||
|
---
|
||||||
23
documentation/docs/60-plugins/10-claude-plugin.md
Normal file
23
documentation/docs/60-plugins/10-claude-plugin.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
title: Claude Code
|
||||||
|
---
|
||||||
|
|
||||||
|
The open source [repository](https://github.com/sveltejs/ai-tools) containing the code for the MCP server is also a Claude Code [plugin marketplace](https://code.claude.com/docs/en/discover-plugins).
|
||||||
|
|
||||||
|
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 — this will help 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/ai-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, install the Svelte plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/plugin install svelte
|
||||||
|
```
|
||||||
54
documentation/docs/60-plugins/20-opencode-plugin.md
Normal file
54
documentation/docs/60-plugins/20-opencode-plugin.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
title: OpenCode
|
||||||
|
---
|
||||||
|
|
||||||
|
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 you can edit your [OpenCode config](https://opencode.ai/docs/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](mcp), [skills](skills), and the `svelte-file-editor` [subagent](subagent) configured for you.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
By default, everything is enabled, but you can configure the plugin by adding a configuration file:
|
||||||
|
|
||||||
|
- locally, in `.opencode/svelte.json`
|
||||||
|
- globally, in `~/.config/opencode/svelte.json` (or, if you have specified the environment variable, in `$OPENCODE_CONFIG_DIR/svelte.json`)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"$schema": "https://svelte.dev/opencode/schema.json",
|
||||||
|
"mcp": {
|
||||||
|
"type": "remote", // or "local" — defaults to remote
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"subagent": {
|
||||||
|
"enabled": true,
|
||||||
|
"agents": {
|
||||||
|
"svelte-file-editor": {
|
||||||
|
"model": "<other-model>", // defaults to the same as main agent
|
||||||
|
"temperature": 1, // defaults to unset
|
||||||
|
"top_p": 0.7, // defaults to unset
|
||||||
|
"maxSteps": 20 // defaults to unlimited
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"skills": {
|
||||||
|
// this can be `true`, or an array of skills to enable
|
||||||
|
// e.g. ["svelte-core-bestpractices"]
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"instructions": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
25
documentation/docs/60-plugins/30-cursor-plugin.md
Normal file
25
documentation/docs/60-plugins/30-cursor-plugin.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
title: Cursor
|
||||||
|
---
|
||||||
|
|
||||||
|
Cursor has a [plugin system](https://cursor.com/docs/plugins) that can bundle rules, skills, agents, commands, MCP servers, and hooks.
|
||||||
|
|
||||||
|
The Svelte plugin gives you the remote Svelte MCP server, Cursor [skills](skills), an always-on rule that tells the model how to use the Svelte MCP tools correctly, and the `svelte-file-editor` subagent for working on `.svelte` files and `.svelte.ts`/`.svelte.js` modules. The source is available in the [`sveltejs/ai-tools`](https://github.com/sveltejs/ai-tools/tree/main/plugins/cursor/svelte) repo.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install the plugin from the [Cursor Marketplace](https://cursor.com/marketplace/svelte) with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
/add-plugin svelte
|
||||||
|
```
|
||||||
|
|
||||||
|
Plugins can be installed either for the current project or at user level.
|
||||||
|
|
||||||
|
Once installed, Cursor will discover the plugin components automatically:
|
||||||
|
|
||||||
|
- the Svelte MCP server is added from the plugin's `.mcp.json`
|
||||||
|
- rules and skills appear in Cursor's rules UI
|
||||||
|
- the `svelte-file-editor` agent becomes available in chat
|
||||||
|
|
||||||
|
> [!NOTE] The Cursor CLI does not support plugins yet. Plugin support in [Cloud Agents](https://cursor.com/docs/cloud-agent) is limited to MCP servers.
|
||||||
36
documentation/docs/60-plugins/40-copilot-plugin.md
Normal file
36
documentation/docs/60-plugins/40-copilot-plugin.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
title: GitHub Copilot CLI
|
||||||
|
---
|
||||||
|
|
||||||
|
The open source [repository](https://github.com/sveltejs/ai-tools) containing the code for the MCP server is also a GitHub Copilot CLI [plugin marketplace](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/plugins-finding-installing).
|
||||||
|
|
||||||
|
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 — this will help save context by handling Svelte-specific tasks more efficiently.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
In VS Code, run the **Install plugin from source** command and use the repository URL:
|
||||||
|
|
||||||
|
```text
|
||||||
|
https://github.com/sveltejs/ai-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also add the repository as a marketplace from the Copilot CLI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
copilot plugin marketplace add sveltejs/ai-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, install the Svelte plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
copilot plugin install svelte@ai-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also run the same commands from an interactive Copilot CLI session:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/plugin marketplace add sveltejs/ai-tools
|
||||||
|
/plugin install svelte@ai-tools
|
||||||
|
```
|
||||||
28
documentation/docs/60-plugins/50-codex-plugin.md
Normal file
28
documentation/docs/60-plugins/50-codex-plugin.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: Codex CLI
|
||||||
|
---
|
||||||
|
|
||||||
|
The open source [repository](https://github.com/sveltejs/ai-tools) containing the code for the MCP server is also a Codex CLI [plugin marketplace](https://developers.openai.com/codex/plugins).
|
||||||
|
|
||||||
|
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 — this will help save context by handling Svelte-specific tasks more efficiently.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Add the repository as a marketplace from the Codex CLI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
codex plugin marketplace add sveltejs/ai-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, open the plugin directory from an interactive Codex CLI session:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
codex
|
||||||
|
/plugins
|
||||||
|
```
|
||||||
|
|
||||||
|
Choose the Svelte marketplace, select the `svelte` plugin, and install it.
|
||||||
|
|
||||||
|
Codex can read the repository's legacy-compatible `.claude-plugin/marketplace.json` marketplace file, so the same marketplace source works for both Claude Code and Codex CLI.
|
||||||
3
documentation/docs/60-plugins/index.md
Normal file
3
documentation/docs/60-plugins/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Plugins
|
||||||
|
---
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
title: MCP
|
title: AI
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -7,13 +7,20 @@ import { fileURLToPath } from 'node:url';
|
|||||||
import ts from 'typescript-eslint';
|
import ts from 'typescript-eslint';
|
||||||
import svelteConfig from './apps/mcp-remote/svelte.config.js';
|
import svelteConfig from './apps/mcp-remote/svelte.config.js';
|
||||||
import eslint_plugin_import from 'eslint-plugin-import';
|
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));
|
const gitignore_path = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
||||||
|
|
||||||
export default /** @type {import("eslint").Linter.Config} */ ([
|
export default /** @type {import("eslint").Linter.Config} */ ([
|
||||||
includeIgnoreFile(gitignore_path),
|
includeIgnoreFile(gitignore_path),
|
||||||
{
|
{
|
||||||
ignores: ['.claude/**/*'],
|
ignores: [
|
||||||
|
'.claude/**/*',
|
||||||
|
'.changeset/*',
|
||||||
|
'.github/**/*.yml',
|
||||||
|
'.github/**/*.yaml',
|
||||||
|
'**/pnpm-lock.yaml',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
...ts.configs.recommended,
|
...ts.configs.recommended,
|
||||||
@@ -37,17 +44,28 @@ export default /** @type {import("eslint").Linter.Config} */ ([
|
|||||||
leadingUnderscore: 'allow',
|
leadingUnderscore: 'allow',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
varsIgnorePattern: '^_',
|
||||||
|
ignoreRestSiblings: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
'func-style': ['error', 'declaration', { allowTypeAnnotation: true }],
|
'func-style': ['error', 'declaration', { allowTypeAnnotation: true }],
|
||||||
'import/no-unresolved': 'off', // this doesn't work well with typescript path mapping
|
'import/no-unresolved': 'off', // this doesn't work well with typescript path mapping
|
||||||
'import/extensions': [
|
'import/extensions': [
|
||||||
'error',
|
'error',
|
||||||
'ignorePackages',
|
|
||||||
{
|
{
|
||||||
js: 'always',
|
ignorePackages: true,
|
||||||
mjs: 'always',
|
pattern: {
|
||||||
cjs: 'always',
|
js: 'always',
|
||||||
ts: 'always',
|
mjs: 'always',
|
||||||
svelte: 'always',
|
cjs: 'always',
|
||||||
|
ts: 'always',
|
||||||
|
svelte: 'always',
|
||||||
|
svg: 'always',
|
||||||
|
json: 'always',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -63,4 +81,16 @@ 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,
|
||||||
]);
|
]);
|
||||||
|
|||||||
58
package.json
58
package.json
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "The official Svelte MCP server implementation",
|
"description": "The official Svelte MCP server implementation",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "pnpm@10.18.1",
|
"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm -r run build",
|
"build": "pnpm -r run build",
|
||||||
"dev": "pnpm --filter @sveltejs/mcp-remote run dev",
|
"dev": "pnpm --filter @sveltejs/mcp-remote run dev",
|
||||||
@@ -12,14 +12,28 @@
|
|||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "prettier --check . && eslint .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"lint:fix": "prettier --write . && eslint . --fix",
|
"lint:fix": "prettier --write . && eslint . --fix",
|
||||||
|
"lint:inspect": "pnpm dlx @eslint/config-inspector",
|
||||||
|
"node:inspect": "pnpm dlx node-modules-inspector",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"test": "npm run test:unit -- --run",
|
"test": "npm run test:unit -- --run",
|
||||||
"test:watch": "npm run test:unit -- --watch",
|
"test:watch": "npm run test:unit -- --watch",
|
||||||
"inspect": "pnpm mcp-inspector",
|
"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": "pnpm --filter @sveltejs/mcp-server run generate-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",
|
||||||
|
"generate-subagent-docs": "cp ./tools/agents/svelte-file-editor.md ./documentation/docs/50-subagents/.generated/subagent.md",
|
||||||
"debug:generate-summaries": "pnpm --filter @sveltejs/mcp-server run debug:generate-summaries",
|
"debug:generate-summaries": "pnpm --filter @sveltejs/mcp-server run debug:generate-summaries",
|
||||||
"release": "pnpm --filter @sveltejs/mcp run build && changeset publish",
|
"release": "pnpm --filter @sveltejs/mcp run build && changeset publish",
|
||||||
"changeset:version": "changeset version && pnpm --filter @sveltejs/mcp run update:version && git add --all"
|
"changeset:version": "changeset version && pnpm --filter @sveltejs/mcp run update:version && git add --all",
|
||||||
|
"sync-plugins": "pnpm sync-claude-plugin && pnpm sync-cursor-plugin && pnpm sync-opencode-plugin && pnpm bump-plugin-versions",
|
||||||
|
"sync-claude-plugin": "node scripts/sync-claude-plugin.ts",
|
||||||
|
"sync-cursor-plugin": "node scripts/sync-cursor-plugin.ts",
|
||||||
|
"sync-opencode-plugin": "node scripts/sync-opencode-plugin.ts && pnpm generate-opencode-jsonschema",
|
||||||
|
"bump-plugin-versions": "node scripts/bump-plugin-versions.ts",
|
||||||
|
"postbump-plugin-versions": "pnpm format",
|
||||||
|
"resolve-references": "node scripts/resolve-references.ts",
|
||||||
|
"postresolve-references": "pnpm format"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"svelte",
|
"svelte",
|
||||||
@@ -29,26 +43,24 @@
|
|||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@changesets/cli": "^2.29.7",
|
"@changesets/cli": "catalog:tooling",
|
||||||
"@eslint/compat": "^1.3.2",
|
"@eslint/compat": "catalog:lint",
|
||||||
"@eslint/js": "^9.36.0",
|
"@eslint/js": "catalog:lint",
|
||||||
"@modelcontextprotocol/inspector": "^0.17.0",
|
"@modelcontextprotocol/inspector": "catalog:ai",
|
||||||
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
"@sveltejs/adapter-vercel": "catalog:svelte",
|
||||||
"eslint": "^9.36.0",
|
"@svitejs/changesets-changelog-github-compact": "catalog:tooling",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint": "catalog:lint",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-config-prettier": "catalog:lint",
|
||||||
"eslint-plugin-svelte": "^3.12.3",
|
"eslint-plugin-import": "catalog:lint",
|
||||||
"globals": "^16.0.0",
|
"eslint-plugin-pnpm": "catalog:lint",
|
||||||
"prettier": "^3.4.2",
|
"eslint-plugin-svelte": "catalog:lint",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"globals": "catalog:lint",
|
||||||
"publint": "^0.3.13",
|
"node-resolve-ts": "catalog:tooling",
|
||||||
"typescript": "^5.0.0",
|
"prettier": "catalog:lint",
|
||||||
"typescript-eslint": "^8.44.1",
|
"prettier-plugin-svelte": "catalog:lint",
|
||||||
"vitest": "^3.2.3"
|
"publint": "catalog:tooling",
|
||||||
},
|
"typescript": "catalog:tooling",
|
||||||
"pnpm": {
|
"typescript-eslint": "catalog:lint",
|
||||||
"onlyBuiltDependencies": [
|
"vitest": "catalog:tooling"
|
||||||
"esbuild"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@sveltejs/mcp-schema",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"private": true,
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"exports": {
|
|
||||||
".": "./src/index.js",
|
|
||||||
"./utils": "./src/utils.js",
|
|
||||||
"./schema": "./src/schema.js"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
|
||||||
"drizzle-orm": "^0.44.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* @import * as schema from './schema.js'
|
|
||||||
*/
|
|
||||||
export * from './schema.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {typeof schema} Schema
|
|
||||||
*/
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
|
||||||
import { float_32_array } from './utils.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: if you modify a schema adding a vector column you need to manually add this
|
|
||||||
*
|
|
||||||
* CREATE INDEX IF NOT EXISTS name_of_the_index
|
|
||||||
* ON `name_of_the_table` (
|
|
||||||
* libsql_vector_idx(name_of_the_column, 'metric=cosine')
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* to the generated migration file
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const distillations = sqliteTable('distillations', {
|
|
||||||
id: integer('id').primaryKey(),
|
|
||||||
preset_name: text('preset_name').notNull(),
|
|
||||||
version: text('version').notNull(),
|
|
||||||
content: text('content').notNull(),
|
|
||||||
size_kb: integer('size_kb').notNull(),
|
|
||||||
document_count: integer('document_count').notNull(),
|
|
||||||
distillation_job_id: integer('distillation_job_id').references(() => distillation_jobs.id),
|
|
||||||
created_at: integer('created_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const distillation_jobs = sqliteTable('distillation_jobs', {
|
|
||||||
id: integer('id').primaryKey(),
|
|
||||||
preset_name: text('preset_name').notNull(),
|
|
||||||
batch_id: text('batch_id'),
|
|
||||||
status: text('status', { enum: ['pending', 'processing', 'completed', 'failed'] }).notNull(),
|
|
||||||
model_used: text('model_used').notNull(),
|
|
||||||
total_files: integer('total_files').notNull(),
|
|
||||||
processed_files: integer('processed_files').notNull().default(0),
|
|
||||||
successful_files: integer('successful_files').notNull().default(0),
|
|
||||||
minimize_applied: integer('minimize_applied', { mode: 'boolean' }).notNull().default(false),
|
|
||||||
total_input_tokens: integer('total_input_tokens').notNull().default(0),
|
|
||||||
total_output_tokens: integer('total_output_tokens').notNull().default(0),
|
|
||||||
started_at: integer('started_at', { mode: 'timestamp' }),
|
|
||||||
completed_at: integer('completed_at', { mode: 'timestamp' }),
|
|
||||||
error_message: text('error_message'),
|
|
||||||
metadata: text('metadata', { mode: 'json' }).notNull().default({}),
|
|
||||||
created_at: integer('created_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
updated_at: integer('updated_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const content = sqliteTable('content', {
|
|
||||||
id: integer('id').primaryKey(),
|
|
||||||
path: text('path').notNull(),
|
|
||||||
filename: text('filename').notNull(),
|
|
||||||
content: text('content').notNull(),
|
|
||||||
size_bytes: integer('size_bytes').notNull(),
|
|
||||||
embeddings: float_32_array('embeddings', { dimensions: 1024 }),
|
|
||||||
metadata: text('metadata', { mode: 'json' }).notNull().default({}),
|
|
||||||
created_at: integer('created_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
updated_at: integer('updated_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const content_distilled = sqliteTable('content_distilled', {
|
|
||||||
id: integer('id').primaryKey(),
|
|
||||||
path: text('path').notNull(),
|
|
||||||
filename: text('filename').notNull(),
|
|
||||||
content: text('content').notNull(),
|
|
||||||
size_bytes: integer('size_bytes').notNull(),
|
|
||||||
embeddings: float_32_array('embeddings', { dimensions: 1024 }),
|
|
||||||
metadata: text('metadata', { mode: 'json' }).notNull().default({}),
|
|
||||||
created_at: integer('created_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
updated_at: integer('updated_at', { mode: 'timestamp' })
|
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date()),
|
|
||||||
});
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* @import { Column } from 'drizzle-orm';
|
|
||||||
*/
|
|
||||||
import { sql } from 'drizzle-orm';
|
|
||||||
import { customType } from 'drizzle-orm/sqlite-core';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to convert an array of embeddings into a format that can be inserted into a LibSQL vector column.
|
|
||||||
* @param {number[]} arr The embeddings array.
|
|
||||||
*/
|
|
||||||
export function vector(arr) {
|
|
||||||
return sql`vector32(${JSON.stringify(arr)})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to calculate the distance between a vector column and an array of embeddings and return it as a columns.
|
|
||||||
* @param {Column} column The drizzle column representing the vector.
|
|
||||||
* @param {number} arr The embeddings array.
|
|
||||||
* @param {string} as The name of the returned column. Default is 'distance'.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* await db.select({
|
|
||||||
* id: vector_table.id,
|
|
||||||
* text: vector_table.text,
|
|
||||||
* distance: distance(vector_table.vector, await get_embeddings(sentence)),
|
|
||||||
* })
|
|
||||||
* .from(vector_table)
|
|
||||||
* .orderBy(sql`distance`)
|
|
||||||
* .execute();
|
|
||||||
*/
|
|
||||||
export function distance(column, arr, as = 'distance') {
|
|
||||||
return /** @type {typeof sql<number>} */ (
|
|
||||||
sql
|
|
||||||
)`CASE ${column} ISNULL WHEN 1 THEN 1 ELSE vector_distance_cos(${column}, vector32(${JSON.stringify(arr)})) END`.as(
|
|
||||||
as,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom drizzle type to use the LibSQL vector column type.
|
|
||||||
*/
|
|
||||||
export const float_32_array = /** @type {typeof customType<{
|
|
||||||
data: number[];
|
|
||||||
config: { dimensions: number };
|
|
||||||
configRequired: true;
|
|
||||||
driverData: Buffer;
|
|
||||||
}>} */ (customType)({
|
|
||||||
dataType(config) {
|
|
||||||
return `F32_BLOB(${config.dimensions})`;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* @param {Buffer} value
|
|
||||||
*/
|
|
||||||
fromDriver(value) {
|
|
||||||
return Array.from(new Float32Array(value.buffer));
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number[]} value
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
toDriver(value) {
|
|
||||||
return vector(value);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -14,32 +14,30 @@
|
|||||||
"debug:generate-summaries": "DEBUG_MODE=1 node scripts/generate-summaries.ts --experimental-strip-types"
|
"debug:generate-summaries": "DEBUG_MODE=1 node scripts/generate-summaries.ts --experimental-strip-types"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts",
|
||||||
},
|
"./handlers": "./src/mcp/handlers/tools/handlers.ts"
|
||||||
"peerDependencies": {
|
|
||||||
"drizzle-orm": "^0.44.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sveltejs/mcp-schema": "workspace:^",
|
"@mcp-ui/server": "catalog:ai",
|
||||||
"@tmcp/adapter-valibot": "^0.1.4",
|
"@tmcp/adapter-valibot": "catalog:tmcp",
|
||||||
"@typescript-eslint/parser": "^8.44.0",
|
"@tmcp/transport-in-memory": "catalog:tmcp",
|
||||||
"eslint": "^9.36.0",
|
"@typescript-eslint/parser": "catalog:lint",
|
||||||
"eslint-plugin-svelte": "^3.12.3",
|
"eslint": "catalog:lint",
|
||||||
"svelte": "^5.39.2",
|
"eslint-plugin-svelte": "catalog:lint",
|
||||||
"svelte-eslint-parser": "^1.3.2",
|
"svelte": "catalog:svelte",
|
||||||
"tmcp": "^1.13.0",
|
"svelte-eslint-parser": "catalog:lint",
|
||||||
"ts-blank-space": "^0.6.2",
|
"tmcp": "catalog:tmcp",
|
||||||
"typescript-eslint": "^8.44.0",
|
"ts-blank-space": "catalog:tooling",
|
||||||
"valibot": "^1.1.0",
|
"typescript-eslint": "catalog:lint",
|
||||||
"vitest": "^3.2.4",
|
"valibot": "catalog:tooling",
|
||||||
"zimmerframe": "^1.1.4"
|
"vitest": "catalog:tooling",
|
||||||
|
"zimmerframe": "catalog:tooling"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@anthropic-ai/sdk": "^0.65.0",
|
"@anthropic-ai/sdk": "catalog:ai",
|
||||||
"@sveltejs/kit": "^2.42.2",
|
"@sveltejs/kit": "catalog:svelte",
|
||||||
"@types/eslint-scope": "^8.3.2",
|
"@types/estree": "catalog:tooling",
|
||||||
"@types/estree": "^1.0.8",
|
"@typescript-eslint/types": "catalog:lint",
|
||||||
"@typescript-eslint/types": "^8.44.0",
|
"dotenv": "catalog:tooling"
|
||||||
"dotenv": "^17.2.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export const base_runes = [
|
|||||||
export const nested_runes = [
|
export const nested_runes = [
|
||||||
'$state.raw',
|
'$state.raw',
|
||||||
'$state.snapshot',
|
'$state.snapshot',
|
||||||
|
'$state.eager',
|
||||||
'$effect.pre',
|
'$effect.pre',
|
||||||
'$effect.tracking',
|
'$effect.tracking',
|
||||||
'$effect.pending',
|
'$effect.pending',
|
||||||
|
|||||||
@@ -344,74 +344,111 @@ describe('add_autofixers_issues', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('imported_runes', () => {
|
describe('imported_runes', () => {
|
||||||
describe.each([{ source: 'svelte' }, { source: 'svelte/runes' }])(
|
describe.each([
|
||||||
'from "$source"',
|
{ source: 'svelte' },
|
||||||
({ source }) => {
|
{ source: 'svelte/runes' },
|
||||||
describe.each(dollarless_runes)('single import ($rune)', ({ rune }) => {
|
{ source: '@sveltejs/runes' },
|
||||||
it(`should add suggestions when importing '${rune}' from '${source}'`, () => {
|
{ source: '@sveltejs/vite-plugin-svelte' },
|
||||||
const content = run_autofixers_on_code(`
|
])('from "$source"', ({ source }) => {
|
||||||
|
describe.each(dollarless_runes)('single import ($rune)', ({ rune }) => {
|
||||||
|
it(`should add suggestions when importing '${rune}' from '${source}'`, () => {
|
||||||
|
const content = run_autofixers_on_code(`
|
||||||
<script>
|
<script>
|
||||||
import { ${rune} } from '${source}';
|
import { ${rune} } from '${source}';
|
||||||
</script>`);
|
</script>`);
|
||||||
|
|
||||||
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
||||||
expect(content.suggestions).toContain(
|
expect(content.suggestions).toContain(
|
||||||
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should add suggestions when importing "${rune}" as the default export from '${source}'`, () => {
|
it(`should add suggestions when importing "${rune}" as the default export from '${source}'`, () => {
|
||||||
const content = run_autofixers_on_code(`
|
const content = run_autofixers_on_code(`
|
||||||
<script>
|
<script>
|
||||||
import ${rune} from '${source}';
|
import ${rune} from '${source}';
|
||||||
</script>`);
|
</script>`);
|
||||||
|
|
||||||
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
||||||
expect(content.suggestions).toContain(
|
expect(content.suggestions).toContain(
|
||||||
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should add suggestions when importing '${rune}' as the namespace export from '${source}'`, () => {
|
it(`should add suggestions when importing '${rune}' as the namespace export from '${source}'`, () => {
|
||||||
const content = run_autofixers_on_code(`
|
const content = run_autofixers_on_code(`
|
||||||
<script>
|
<script>
|
||||||
import * as ${rune} from '${source}';
|
import * as ${rune} from '${source}';
|
||||||
</script>`);
|
</script>`);
|
||||||
|
|
||||||
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
expect(content.suggestions.length).toBeGreaterThanOrEqual(1);
|
||||||
expect(content.suggestions).toContain(
|
expect(content.suggestions).toContain(
|
||||||
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
`You are importing "${rune}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it(`should add suggestions when importing multiple runes from '${source}'`, () => {
|
it(`should add suggestions when importing multiple runes from '${source}'`, () => {
|
||||||
const content = run_autofixers_on_code(`
|
const content = run_autofixers_on_code(`
|
||||||
<script>
|
<script>
|
||||||
import { onMount, state, effect } from '${source}';
|
import { onMount, state, effect } from '${source}';
|
||||||
</script>`);
|
</script>`);
|
||||||
|
|
||||||
expect(content.suggestions.length).toBeGreaterThanOrEqual(2);
|
expect(content.suggestions.length).toBeGreaterThanOrEqual(2);
|
||||||
expect(content.suggestions).toContain(
|
expect(content.suggestions).toContain(
|
||||||
`You are importing "state" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$state" directly.`,
|
`You are importing "state" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$state" directly.`,
|
||||||
);
|
);
|
||||||
expect(content.suggestions).toContain(
|
expect(content.suggestions).toContain(
|
||||||
`You are importing "effect" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$effect" directly.`,
|
`You are importing "effect" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$effect" directly.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not add suggestions when importing other identifiers from '${source}'`, () => {
|
it(`should not add suggestions when importing other identifiers from '${source}'`, () => {
|
||||||
const content = run_autofixers_on_code(`
|
const content = run_autofixers_on_code(`
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from '${source}';
|
import { onMount } from '${source}';
|
||||||
</script>`);
|
</script>`);
|
||||||
|
|
||||||
expect(content.suggestions).not.toContain(
|
expect(content.suggestions).not.toContain(
|
||||||
`You are importing "onMount" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$onMount" directly.`,
|
`You are importing "onMount" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$onMount" directly.`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
describe.each(dollarless_runes)('importing $rune from external lib', ({ rune }) => {
|
||||||
|
it(`should not add suggestions when importing from packages whose name doesn't contain svelte`, () => {
|
||||||
|
const content = run_autofixers_on_code(`
|
||||||
|
<script>
|
||||||
|
import { ${rune} } from 'something-something';
|
||||||
|
</script>`);
|
||||||
|
|
||||||
|
expect(content.suggestions).not.toContain(
|
||||||
|
`You are importing "${rune}" from "something-something". This is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly.`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should add suggestions with a different hint when importing from packages whose name contains svelte but it's not official`, () => {
|
||||||
|
const content = run_autofixers_on_code(`
|
||||||
|
<script>
|
||||||
|
import { ${rune} } from 'svelte-something-something';
|
||||||
|
</script>`);
|
||||||
|
|
||||||
|
expect(content.suggestions).toContain(
|
||||||
|
`You are importing "${rune}" from "svelte-something-something". If you are trying to import runes to use them this is not necessary, all runes are globally available. Please remove this import and use "$${rune}" directly. If you are importing the function from a separate library ignore this suggestion.`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add the imported_runes suggestion when importing derived from svelte/store', () => {
|
||||||
|
const content = run_autofixers_on_code(`
|
||||||
|
<script>
|
||||||
|
import { derived } from 'svelte/store';
|
||||||
|
</script>`);
|
||||||
|
|
||||||
|
expect(content.suggestions).not.toContain(
|
||||||
|
'You are importing "derived" from "svelte/store". This is not necessary, all runes are globally available. Please remove this import and use "$derived" directly.',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('derived_with_function', () => {
|
describe('derived_with_function', () => {
|
||||||
@@ -687,4 +724,67 @@ describe('add_autofixers_issues', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('read_state_with_dollar', () => {
|
||||||
|
with_possible_inits('($init)', ({ init }) => {
|
||||||
|
it(`should add an issue when reading a stateful variable initialized with ${init} like if it was a store`, () => {
|
||||||
|
const content = run_autofixers_on_code(`<script>
|
||||||
|
let x = ${init}(()=> 43);
|
||||||
|
$x;
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
|
||||||
|
expect(content.issues).toContain(
|
||||||
|
`You are reading the stateful variable "$x" with a "$" prefix. Stateful variables are not stores and should be read without the "$". Please read it as a normal variable "x"`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not add an issue when reading an imported variable like if it was a store`, () => {
|
||||||
|
const content = run_autofixers_on_code(`<script>
|
||||||
|
import { x } from "./my-stores.ts";
|
||||||
|
$x;
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
|
||||||
|
expect(content.issues).not.toContain(
|
||||||
|
`You are reading the stateful variable "$x" with a "$" prefix. Stateful variables are not stores and should be read without the "$". Please read it as a normal variable "x"`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not add an issue when reading a non-stateful variable like if it was a store`, () => {
|
||||||
|
const content = run_autofixers_on_code(`<script>
|
||||||
|
import { writable } from "svelte/store";
|
||||||
|
const x = writable(0);
|
||||||
|
$x;
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
|
||||||
|
expect(content.issues).not.toContain(
|
||||||
|
`You are reading the stateful variable "$x" with a "$" prefix. Stateful variables are not stores and should be read without the "$". Please read it as a normal variable "x"`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not add an issue when reading a prop like if it was a store`, () => {
|
||||||
|
const content = run_autofixers_on_code(`<script>
|
||||||
|
const { x } = $props();
|
||||||
|
$x;
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
|
||||||
|
expect(content.issues).not.toContain(
|
||||||
|
`You are reading the stateful variable "$x" with a "$" prefix. Stateful variables are not stores and should be read without the "$". Please read it as a normal variable "x"`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://github.com/sveltejs/ai-tools/issues/200
|
||||||
|
it('should not crash when reading $-prefixed identifier for variable initialized with member expression', () => {
|
||||||
|
expect(() =>
|
||||||
|
run_autofixers_on_code(`<div>{$x}</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const x = foo.bar;
|
||||||
|
</script>`),
|
||||||
|
).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export function add_autofixers_issues(
|
|||||||
code: string,
|
code: string,
|
||||||
desired_svelte_version: number,
|
desired_svelte_version: number,
|
||||||
filename = 'Component.svelte',
|
filename = 'Component.svelte',
|
||||||
|
async = false,
|
||||||
) {
|
) {
|
||||||
const parsed = parse(code, filename);
|
const parsed = parse(code, filename);
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ export function add_autofixers_issues(
|
|||||||
for (const autofixer of Object.values(autofixers)) {
|
for (const autofixer of Object.values(autofixers)) {
|
||||||
walk(
|
walk(
|
||||||
parsed.ast as unknown as Node,
|
parsed.ast as unknown as Node,
|
||||||
{ output: content, parsed, desired_svelte_version },
|
{ output: content, parsed, desired_svelte_version, async },
|
||||||
autofixer,
|
autofixer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function add_compile_issues(
|
|||||||
code: string,
|
code: string,
|
||||||
desired_svelte_version: number,
|
desired_svelte_version: number,
|
||||||
filename = 'Component.svelte',
|
filename = 'Component.svelte',
|
||||||
|
async = false,
|
||||||
) {
|
) {
|
||||||
let compile = compile_component;
|
let compile = compile_component;
|
||||||
const extension = extname(filename);
|
const extension = extname(filename);
|
||||||
@@ -27,6 +28,7 @@ export function add_compile_issues(
|
|||||||
filename: filename || 'Component.svelte',
|
filename: filename || 'Component.svelte',
|
||||||
generate: false,
|
generate: false,
|
||||||
runes: desired_svelte_version >= 5,
|
runes: desired_svelte_version >= 5,
|
||||||
|
experimental: { async },
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const warning of compilation_result.warnings) {
|
for (const warning of compilation_result.warnings) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ function base_config(svelte_config: Config): ESLint.Options['baseConfig'] {
|
|||||||
'svelte/prefer-writable-derived': 'warn',
|
'svelte/prefer-writable-derived': 'warn',
|
||||||
'svelte/require-event-dispatcher-types': 'warn',
|
'svelte/require-event-dispatcher-types': 'warn',
|
||||||
'svelte/require-store-reactive-access': 'warn',
|
'svelte/require-store-reactive-access': 'warn',
|
||||||
|
'svelte/no-inspect': 'off',
|
||||||
},
|
},
|
||||||
|
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
@@ -51,7 +52,7 @@ function base_config(svelte_config: Config): ESLint.Options['baseConfig'] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_linter(version: number) {
|
function get_linter(version: number, async = false) {
|
||||||
if (version < 5) {
|
if (version < 5) {
|
||||||
return (svelte_4_linter ??= new ESLint({
|
return (svelte_4_linter ??= new ESLint({
|
||||||
overrideConfigFile: true,
|
overrideConfigFile: true,
|
||||||
@@ -67,6 +68,7 @@ function get_linter(version: number) {
|
|||||||
baseConfig: base_config({
|
baseConfig: base_config({
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
runes: true,
|
runes: true,
|
||||||
|
experimental: { async },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
@@ -77,8 +79,9 @@ export async function add_eslint_issues(
|
|||||||
code: string,
|
code: string,
|
||||||
desired_svelte_version: number,
|
desired_svelte_version: number,
|
||||||
filename = 'Component.svelte',
|
filename = 'Component.svelte',
|
||||||
|
async = false,
|
||||||
) {
|
) {
|
||||||
const eslint = get_linter(desired_svelte_version);
|
const eslint = get_linter(desired_svelte_version, async);
|
||||||
const results = await eslint.lintText(code, { filePath: filename || './Component.svelte' });
|
const results = await eslint.lintText(code, { filePath: filename || './Component.svelte' });
|
||||||
|
|
||||||
for (const message of results[0]?.messages ?? []) {
|
for (const message of results[0]?.messages ?? []) {
|
||||||
|
|||||||
@@ -3,10 +3,20 @@ import type { Autofixer } from './index.js';
|
|||||||
|
|
||||||
const dollarless_runes = base_runes.map((r) => r.replace('$', ''));
|
const dollarless_runes = base_runes.map((r) => r.replace('$', ''));
|
||||||
|
|
||||||
|
function should_suggest_for_source(source: string, rune: string) {
|
||||||
|
if (!source.includes('svelte')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (source === 'svelte/store' && rune === 'derived') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export const imported_runes: Autofixer = {
|
export const imported_runes: Autofixer = {
|
||||||
ImportDeclaration(node, { state, next }) {
|
ImportDeclaration(node, { state, next }) {
|
||||||
const source = (node.source.value || node.source.raw?.slice(1, -1))?.toString();
|
const source = (node.source.value || node.source.raw?.slice(1, -1))?.toString();
|
||||||
if (source && source.startsWith('svelte')) {
|
if (source) {
|
||||||
for (const specifier of node.specifiers) {
|
for (const specifier of node.specifiers) {
|
||||||
const id =
|
const id =
|
||||||
specifier.type === 'ImportDefaultSpecifier'
|
specifier.type === 'ImportDefaultSpecifier'
|
||||||
@@ -16,10 +26,25 @@ export const imported_runes: Autofixer = {
|
|||||||
: specifier.type === 'ImportSpecifier'
|
: specifier.type === 'ImportSpecifier'
|
||||||
? specifier.imported
|
? specifier.imported
|
||||||
: null;
|
: null;
|
||||||
if (id && id.type === 'Identifier' && dollarless_runes.includes(id.name)) {
|
if (
|
||||||
state.output.suggestions.push(
|
id &&
|
||||||
`You are importing "${id.name}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${id.name}" directly.`,
|
id.type === 'Identifier' &&
|
||||||
);
|
dollarless_runes.includes(id.name) &&
|
||||||
|
should_suggest_for_source(source, id.name)
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
source === 'svelte' ||
|
||||||
|
source.startsWith('svelte/') ||
|
||||||
|
source.startsWith('@sveltejs')
|
||||||
|
) {
|
||||||
|
state.output.suggestions.push(
|
||||||
|
`You are importing "${id.name}" from "${source}". This is not necessary, all runes are globally available. Please remove this import and use "$${id.name}" directly.`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
state.output.suggestions.push(
|
||||||
|
`You are importing "${id.name}" from "${source}". If you are trying to import runes to use them this is not necessary, all runes are globally available. Please remove this import and use "$${id.name}" directly. If you are importing the function from a separate library ignore this suggestion.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type AutofixerState = {
|
|||||||
output: { issues: string[]; suggestions: string[] };
|
output: { issues: string[]; suggestions: string[] };
|
||||||
parsed: ParseResult;
|
parsed: ParseResult;
|
||||||
desired_svelte_version: number;
|
desired_svelte_version: number;
|
||||||
|
async?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Autofixer = Visitors<Node | AST.SvelteNode, AutofixerState>;
|
export type Autofixer = Visitors<Node | AST.SvelteNode, AutofixerState>;
|
||||||
@@ -17,3 +18,4 @@ export * from './imported-runes.js';
|
|||||||
export * from './derived-with-function.js';
|
export * from './derived-with-function.js';
|
||||||
export * from './use-runes-instead-of-store.js';
|
export * from './use-runes-instead-of-store.js';
|
||||||
export * from './suggest-attachments.js';
|
export * from './suggest-attachments.js';
|
||||||
|
export * from './read-state-with-dollar.js';
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type { Autofixer } from './index.js';
|
||||||
|
|
||||||
|
export const read_state_with_dollar: Autofixer = {
|
||||||
|
Identifier(node, { state }) {
|
||||||
|
if (node.name.startsWith('$')) {
|
||||||
|
const reference = state.parsed.find_reference_by_id(node);
|
||||||
|
if (reference && reference.resolved && reference.resolved.defs[0]?.node?.init) {
|
||||||
|
const is_state = state.parsed.is_rune(reference.resolved.defs[0].node.init, [
|
||||||
|
'$state',
|
||||||
|
'$state.raw',
|
||||||
|
'$derived',
|
||||||
|
'$derived.by',
|
||||||
|
]);
|
||||||
|
if (is_state) {
|
||||||
|
state.output.issues.push(
|
||||||
|
`You are reading the stateful variable "${node.name}" with a "$" prefix. Stateful variables are not stores and should be read without the "$". Please read it as a normal variable "${node.name.substring(1)}"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -25,7 +25,6 @@ export const suggest_attachments: Autofixer = {
|
|||||||
if (id) {
|
if (id) {
|
||||||
const reference = state.parsed.find_reference_by_id(id);
|
const reference = state.parsed.find_reference_by_id(id);
|
||||||
const definition = reference?.resolved?.defs[0];
|
const definition = reference?.resolved?.defs[0];
|
||||||
console.log(definition);
|
|
||||||
if (
|
if (
|
||||||
definition &&
|
definition &&
|
||||||
(definition.type === 'Variable' ||
|
(definition.type === 'Variable' ||
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export * from './svelte-task.js';
|
export { setup_svelte_task } from './svelte-task.js';
|
||||||
|
|||||||
@@ -1,32 +1,23 @@
|
|||||||
import type { SvelteMcp } from '../../index.js';
|
import type { SvelteMcp } from '../../index.js';
|
||||||
import * as v from 'valibot';
|
import * as v from 'valibot';
|
||||||
import { format_sections_list } from '../../utils.js';
|
import { format_sections_list } from '../../utils.js';
|
||||||
|
import { icons } from '../../icons/index.js';
|
||||||
|
import { prompt } from 'tmcp/utils';
|
||||||
|
|
||||||
export function setup_svelte_task(server: SvelteMcp) {
|
/**
|
||||||
server.prompt(
|
* 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).
|
||||||
name: 'svelte-task-prompt',
|
*/
|
||||||
title: 'Svelte-Task-Prompt',
|
function svelte_task(available_docs: string, task: string) {
|
||||||
description:
|
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!
|
||||||
'Use this Prompt to ask for any svelte related task. It will automatically instruct the LLM on how to best use the autofixer and how to query for documentation pages.',
|
|
||||||
schema: v.object({
|
|
||||||
task: v.pipe(v.string(), v.description('The task to be performed')),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
async ({ task }) => {
|
|
||||||
const available_docs = await format_sections_list();
|
|
||||||
|
|
||||||
return {
|
|
||||||
messages: [
|
|
||||||
{
|
|
||||||
role: 'user',
|
|
||||||
content: {
|
|
||||||
type: 'text',
|
|
||||||
text: `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}
|
${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.
|
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:
|
This is the task you will work on:
|
||||||
@@ -35,12 +26,57 @@ This is the task you will work on:
|
|||||||
${task}
|
${task}
|
||||||
</task>
|
</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.
|
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.`;
|
||||||
`,
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to generate the prompt to update the docs in the script `/scripts/update-docs-prompts.ts` it should use the default export
|
||||||
|
* function and pass in the arguments. Since it will be included in the documentation if it's an argument that the MCP will expose it should
|
||||||
|
* be in the format [NAME_OF_THE_ARGUMENT] to signal the user that it can substitute it.
|
||||||
|
*
|
||||||
|
* The name NEEDS to be `generate_for_docs`.
|
||||||
|
*/
|
||||||
|
export async function generate_for_docs() {
|
||||||
|
const available_docs = await format_sections_list();
|
||||||
|
return svelte_task(available_docs, '[YOUR TASK HERE]');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human readable description of what the prompt does. It will be included in the documentation.
|
||||||
|
*
|
||||||
|
* The name NEEDS to be `docs_description`.
|
||||||
|
*/
|
||||||
|
export const docs_description =
|
||||||
|
'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.';
|
||||||
|
|
||||||
|
export function setup_svelte_task(server: SvelteMcp) {
|
||||||
|
server.prompt(
|
||||||
|
{
|
||||||
|
name: 'svelte-task',
|
||||||
|
title: 'Svelte-Task-Prompt',
|
||||||
|
description:
|
||||||
|
'Use this Prompt to ask for any svelte related task. It will automatically instruct the LLM on how to best use the autofixer and how to query for documentation pages.',
|
||||||
|
schema: v.object({
|
||||||
|
task: v.pipe(v.string(), v.description('The task to be performed')),
|
||||||
|
}),
|
||||||
|
complete: {
|
||||||
|
task() {
|
||||||
|
return {
|
||||||
|
completion: {
|
||||||
|
values: [''],
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
],
|
},
|
||||||
};
|
},
|
||||||
|
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));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import type { SvelteMcp } from '../../index.js';
|
import type { SvelteMcp } from '../../index.js';
|
||||||
import { get_sections, fetch_with_timeout } from '../../utils.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) {
|
export async function list_sections(server: SvelteMcp) {
|
||||||
const sections = await get_sections();
|
const sections = await get_sections();
|
||||||
@@ -42,23 +44,23 @@ export async function list_sections(server: SvelteMcp) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
uri: 'svelte://{/slug*}.md',
|
uri: 'svelte://{/slug*}.md',
|
||||||
|
icons,
|
||||||
},
|
},
|
||||||
async (uri, { slug }) => {
|
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) => {
|
const section = sections.find((section) => {
|
||||||
return slug === section.slug;
|
return slug === section.slug;
|
||||||
});
|
});
|
||||||
if (!section) throw new Error(`Section not found: ${slug}`);
|
if (!section) throw new Error(`Section not found: ${slug}`);
|
||||||
const response = await fetch_with_timeout(section.url);
|
const response = await fetch_with_timeout(section.url);
|
||||||
const content = await response.text();
|
const content = await response.text();
|
||||||
return {
|
return resource.text(uri, content);
|
||||||
contents: [
|
|
||||||
{
|
|
||||||
uri,
|
|
||||||
type: 'text',
|
|
||||||
text: content,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,114 +2,180 @@ import type { SvelteMcp } from '../../index.js';
|
|||||||
import * as v from 'valibot';
|
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 } from '../../utils.js';
|
||||||
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.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 successes = results.filter((r) => r.success);
|
||||||
|
const failed_sections = sections.filter(
|
||||||
|
(s) =>
|
||||||
|
!available_sections.some(
|
||||||
|
(a) => a.title.toLowerCase() === s.toLowerCase() || a.slug === s || a.url === s,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (successes.length > 0 && failed_sections.length === 0) {
|
||||||
|
return successes.map((r) => r.content).join('\n\n---\n\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts: string[] = [];
|
||||||
|
|
||||||
|
if (successes.length > 0) {
|
||||||
|
parts.push(successes.map((r) => r.content).join('\n\n---\n\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const fuzzy_results = failed_sections.map((requested) => {
|
||||||
|
const lower = requested.toLowerCase();
|
||||||
|
const matches = available_sections.filter(
|
||||||
|
(a) =>
|
||||||
|
a.title.toLowerCase().includes(lower) ||
|
||||||
|
a.slug.includes(lower) ||
|
||||||
|
lower.includes(a.slug.split('/').pop() ?? '') ||
|
||||||
|
a.use_cases.toLowerCase().includes(lower),
|
||||||
|
);
|
||||||
|
return { requested, matches };
|
||||||
|
});
|
||||||
|
|
||||||
|
const has_fuzzy = fuzzy_results.some((r) => r.matches.length > 0);
|
||||||
|
|
||||||
|
// Full list only when no successes and no fuzzy matches
|
||||||
|
if (successes.length === 0 && !has_fuzzy) {
|
||||||
|
const formatted_sections = await format_sections_list();
|
||||||
|
parts.push(`${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similar results then errors
|
||||||
|
for (const { requested, matches } of fuzzy_results) {
|
||||||
|
if (matches.length > 0) {
|
||||||
|
const match_list = matches.map((m) => `- title: ${m.title}, section: ${m.slug}`).join('\n');
|
||||||
|
parts.push(
|
||||||
|
`${matches.length} similar result${matches.length > 1 ? 's' : ''} for "${requested}":\n${match_list}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
parts.push(`Section not found: "${requested}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts.join('\n\n---\n\n');
|
||||||
|
}
|
||||||
|
|
||||||
export function get_documentation(server: SvelteMcp) {
|
export function get_documentation(server: SvelteMcp) {
|
||||||
server.tool(
|
server.tool(
|
||||||
{
|
{
|
||||||
name: 'get-documentation',
|
name: 'get-documentation',
|
||||||
description:
|
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.',
|
'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: v.object({
|
schema: get_documentation_schema,
|
||||||
section: v.pipe(
|
annotations: {
|
||||||
v.union([v.string(), v.array(v.string())]),
|
title: 'Get Documentation',
|
||||||
v.description(
|
destructiveHint: false,
|
||||||
'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',
|
readOnlyHint: true,
|
||||||
),
|
openWorldHint: false,
|
||||||
),
|
},
|
||||||
}),
|
icons,
|
||||||
},
|
},
|
||||||
async ({ section }) => {
|
async ({ section }) => {
|
||||||
let sections: string[];
|
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||||
|
await server.ctx.custom?.track?.(server.ctx.sessionId, 'get-documentation');
|
||||||
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 = [];
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const available_sections = await get_sections();
|
const content = await get_documentation_handler({ section });
|
||||||
|
return tool.text(content);
|
||||||
const settled_results = await Promise.allSettled(
|
} catch (e) {
|
||||||
sections.map(async (requested_section) => {
|
const error = e as Error;
|
||||||
const matched_section = available_sections.find(
|
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||||
(s) =>
|
await server.ctx.custom?.track?.(
|
||||||
s.title.toLowerCase() === requested_section.toLowerCase() ||
|
server.ctx.sessionId,
|
||||||
s.slug === requested_section ||
|
'get-documentation-error',
|
||||||
s.url === requested_section,
|
error.message,
|
||||||
);
|
);
|
||||||
|
|
||||||
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}`,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
return tool.error(error.message);
|
||||||
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
4
packages/mcp-server/src/mcp/handlers/tools/handlers.ts
Normal file
4
packages/mcp-server/src/mcp/handlers/tools/handlers.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
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';
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export * from './get-documentation.js';
|
export { get_documentation } from './get-documentation.js';
|
||||||
export * from './list-sections.js';
|
export { list_sections } from './list-sections.js';
|
||||||
export * from './svelte-autofixer.js';
|
export { svelte_autofixer } from './svelte-autofixer.js';
|
||||||
export * from './playground-link.js';
|
export { playground_link } from './playground-link.js';
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import type { SvelteMcp } from '../../index.js';
|
import type { SvelteMcp } from '../../index.js';
|
||||||
import { format_sections_list } from '../../utils.js';
|
import { format_sections_list } from '../../utils.js';
|
||||||
import { SECTIONS_LIST_INTRO, SECTIONS_LIST_OUTRO } from './prompts.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) {
|
export function list_sections(server: SvelteMcp) {
|
||||||
server.tool(
|
server.tool(
|
||||||
@@ -8,18 +16,32 @@ export function list_sections(server: SvelteMcp) {
|
|||||||
name: 'list-sections',
|
name: 'list-sections',
|
||||||
description:
|
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.',
|
'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 () => {
|
async () => {
|
||||||
const formatted_sections = await format_sections_list();
|
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||||
|
await server.ctx.custom?.track?.(server.ctx.sessionId, 'list-sections');
|
||||||
return {
|
}
|
||||||
content: [
|
try {
|
||||||
{
|
const content = await list_sections_handler();
|
||||||
type: 'text',
|
return tool.text(content);
|
||||||
text: `${SECTIONS_LIST_INTRO}\n\n${formatted_sections}\n\n${SECTIONS_LIST_OUTRO}`,
|
} 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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
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',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import type { SvelteMcp } from '../../index.js';
|
import { createUIResource } from '@mcp-ui/server';
|
||||||
|
import { tool } from 'tmcp/utils';
|
||||||
import * as v from 'valibot';
|
import * as v from 'valibot';
|
||||||
|
import { icons } from '../../icons/index.js';
|
||||||
|
import type { SvelteMcp } from '../../index.js';
|
||||||
|
|
||||||
async function compress_and_encode_text(input: string) {
|
async function compress_and_encode_text(input: string) {
|
||||||
const reader = new Blob([input]).stream().pipeThrough(new CompressionStream('gzip')).getReader();
|
const reader = new Blob([input]).stream().pipeThrough(new CompressionStream('gzip')).getReader();
|
||||||
@@ -27,86 +30,232 @@ type File = {
|
|||||||
text: boolean;
|
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) {
|
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(
|
server.tool(
|
||||||
{
|
{
|
||||||
name: 'playground-link',
|
name: 'playground-link',
|
||||||
description:
|
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.',
|
'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: v.object({
|
schema: playground_link_schema,
|
||||||
name: v.pipe(
|
outputSchema: playground_link_output_schema,
|
||||||
v.string(),
|
annotations: {
|
||||||
v.description('The name of the Playground, it should reflect the user task'),
|
title: 'Playground Link',
|
||||||
),
|
destructiveHint: false,
|
||||||
tailwind: v.pipe(
|
readOnlyHint: true,
|
||||||
v.boolean(),
|
openWorldHint: false,
|
||||||
v.description(
|
},
|
||||||
"If the code requires Tailwind CSS to work...only send true if it it's using tailwind classes in the code",
|
icons,
|
||||||
),
|
// For MCP Apps hosts - points to the registered resource
|
||||||
),
|
_meta: {
|
||||||
files: v.pipe(
|
ui: {
|
||||||
v.record(v.string(), v.string()),
|
resourceUri: playground_ui_resource.resource.uri,
|
||||||
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 }) => {
|
async ({ files, name, tailwind }) => {
|
||||||
const playground_base = new URL('https://svelte.dev/playground');
|
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||||
const playground_files: File[] = [];
|
await server.ctx.custom?.track?.(server.ctx.sessionId, 'playground-link');
|
||||||
|
|
||||||
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 {
|
||||||
if (!has_app_svelte) {
|
const result = await playground_link_handler({ files, name, tailwind });
|
||||||
return {
|
return {
|
||||||
isError: true,
|
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
text: JSON.stringify({
|
text: JSON.stringify({ url: result.url }),
|
||||||
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,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import { writeFileSync, unlinkSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
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,
|
||||||
|
ctx?: { stdio?: boolean },
|
||||||
|
) {
|
||||||
|
const result = await session.callTool(
|
||||||
|
'svelte-autofixer',
|
||||||
|
{
|
||||||
|
code,
|
||||||
|
desired_svelte_version,
|
||||||
|
filename: 'App.svelte',
|
||||||
|
async,
|
||||||
|
},
|
||||||
|
ctx,
|
||||||
|
);
|
||||||
|
|
||||||
|
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"',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should read file content from path when stdio context is true', async () => {
|
||||||
|
const tmp_file = join(tmpdir(), `svelte-autofixer-test-${Date.now()}.svelte`);
|
||||||
|
const file_content = `<script>
|
||||||
|
$state count = 0;
|
||||||
|
</script>`;
|
||||||
|
|
||||||
|
writeFileSync(tmp_file, file_content, 'utf-8');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// with stdio: true, the file is read from disk and parsed, producing issues
|
||||||
|
const content = await autofixer_tool_call(tmp_file, false, 5, false, { stdio: true });
|
||||||
|
expect(content.issues.length).toBeGreaterThan(0);
|
||||||
|
expect(content.suggestions.length).toBeGreaterThan(0);
|
||||||
|
} finally {
|
||||||
|
unlinkSync(tmp_file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should treat file path as code when stdio context is not set', async () => {
|
||||||
|
const tmp_file = join(tmpdir(), `svelte-autofixer-test-${Date.now()}.svelte`);
|
||||||
|
const file_content = `<script>
|
||||||
|
$state count = 0;
|
||||||
|
</script>`;
|
||||||
|
|
||||||
|
writeFileSync(tmp_file, file_content, 'utf-8');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// without stdio context, the path string is treated as raw code (plain text), no issues
|
||||||
|
const content = await autofixer_tool_call(tmp_file, false, 5, false);
|
||||||
|
expect(content.issues).toHaveLength(0);
|
||||||
|
expect(content.suggestions).toHaveLength(0);
|
||||||
|
} finally {
|
||||||
|
unlinkSync(tmp_file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,9 +1,121 @@
|
|||||||
import { basename } from 'node:path';
|
import { basename } from 'node:path';
|
||||||
import type { SvelteMcp } from '../../index.js';
|
import { tool } from 'tmcp/utils';
|
||||||
import * as v from 'valibot';
|
import * as v from 'valibot';
|
||||||
|
import { add_autofixers_issues } from '../../autofixers/add-autofixers-issues.js';
|
||||||
import { add_compile_issues } from '../../autofixers/add-compile-issues.js';
|
import { add_compile_issues } from '../../autofixers/add-compile-issues.js';
|
||||||
import { add_eslint_issues } from '../../autofixers/add-eslint-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 { type SvelteMcp } from '../../index.js';
|
||||||
|
|
||||||
|
let cached_schema: ReturnType<typeof get_autofixer_schema> | null = null;
|
||||||
|
|
||||||
|
function get_autofixer_schema(stdio: boolean) {
|
||||||
|
let code = v.string();
|
||||||
|
if (stdio) {
|
||||||
|
// we only add the description if we are running in stdio, this saves a few tokens for the remote server
|
||||||
|
code = v.pipe(
|
||||||
|
v.string(),
|
||||||
|
v.description(
|
||||||
|
"The code to be processed by the autofixer. It can also be a path to a file containing the code. If the file doesn't exists the string will be treated as the code",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return v.object({
|
||||||
|
code,
|
||||||
|
desired_svelte_version: v.pipe(
|
||||||
|
v.union([v.string(), v.number()]),
|
||||||
|
v.description(
|
||||||
|
'The desired major svelte version as an integer (must be 4 or 5)...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<ReturnType<typeof get_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) {
|
export function svelte_autofixer(server: SvelteMcp) {
|
||||||
server.tool(
|
server.tool(
|
||||||
@@ -12,75 +124,60 @@ export function svelte_autofixer(server: SvelteMcp) {
|
|||||||
title: 'Svelte Autofixer',
|
title: 'Svelte Autofixer',
|
||||||
description:
|
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',
|
'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: v.object({
|
get schema() {
|
||||||
code: v.string(),
|
return (
|
||||||
desired_svelte_version: v.pipe(
|
cached_schema ?? (cached_schema = get_autofixer_schema(server.ctx.custom?.stdio ?? false))
|
||||||
v.union([v.literal(4), v.literal(5), v.literal('4'), v.literal('5')]),
|
);
|
||||||
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.',
|
outputSchema: autofixer_output_schema,
|
||||||
),
|
|
||||||
),
|
|
||||||
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: {
|
annotations: {
|
||||||
title: 'Svelte Autofixer',
|
title: 'Svelte Autofixer',
|
||||||
destructiveHint: false,
|
destructiveHint: false,
|
||||||
readOnlyHint: true,
|
readOnlyHint: true,
|
||||||
openWorldHint: false,
|
openWorldHint: false,
|
||||||
},
|
},
|
||||||
|
icons,
|
||||||
},
|
},
|
||||||
async ({ code, filename: filename_or_path, desired_svelte_version }) => {
|
async ({
|
||||||
const content: {
|
code,
|
||||||
issues: string[];
|
filename: filename_or_path,
|
||||||
suggestions: string[];
|
desired_svelte_version: desired_svelte_version_unchecked,
|
||||||
require_another_tool_call_after_fixing: boolean;
|
async,
|
||||||
} = { issues: [], suggestions: [], require_another_tool_call_after_fixing: false };
|
}) => {
|
||||||
try {
|
if (server.ctx.sessionId && server.ctx.custom?.track) {
|
||||||
// just in case the LLM sends a full path we extract the filename...it's not really needed
|
await server.ctx.custom?.track?.(server.ctx.sessionId, 'svelte-autofixer');
|
||||||
// but it's nice to have a filename in the errors
|
}
|
||||||
|
|
||||||
const filename = filename_or_path ? basename(filename_or_path) : 'Component.svelte';
|
// we only do this if we know we are running in stdio mode (only stdio pass the context as true)
|
||||||
|
if (server.ctx.custom?.stdio) {
|
||||||
add_compile_issues(content, code, +desired_svelte_version, filename);
|
const [exists_sync, read_file] = await Promise.all([
|
||||||
|
import('node:fs').then((mod) => mod.existsSync),
|
||||||
add_autofixers_issues(content, code, +desired_svelte_version, filename);
|
import('node:fs/promises').then((mod) => mod.readFile),
|
||||||
|
]);
|
||||||
await add_eslint_issues(content, code, +desired_svelte_version, filename);
|
if (exists_sync(code)) {
|
||||||
} catch (e: unknown) {
|
code = await read_file(code, 'utf-8');
|
||||||
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)`.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.issues.length > 0 || content.suggestions.length > 0) {
|
try {
|
||||||
content.require_another_tool_call_after_fixing = true;
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return tool.error(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: 'text',
|
|
||||||
text: JSON.stringify(content),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
structuredContent: content,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
14
packages/mcp-server/src/mcp/icons/index.ts
Normal file
14
packages/mcp-server/src/mcp/icons/index.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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',
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
|
import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
|
||||||
import { McpServer } from 'tmcp';
|
import { McpServer } from 'tmcp';
|
||||||
import { setup_prompts, setup_resources, setup_tools } from './handlers/index.js';
|
import { setup_prompts, setup_resources, setup_tools } from './handlers/index.js';
|
||||||
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
import { icons } from './icons/index.js';
|
||||||
import type { Schema } from '@sveltejs/mcp-schema';
|
|
||||||
|
|
||||||
export const server = new McpServer(
|
export const server = new McpServer(
|
||||||
{
|
{
|
||||||
name: 'Svelte MCP',
|
name: 'Svelte MCP',
|
||||||
version: '0.0.1',
|
version: '0.0.1',
|
||||||
description: 'The official Svelte MCP server implementation',
|
description: 'The official Svelte MCP server implementation',
|
||||||
|
websiteUrl: 'https://mcp.svelte.dev',
|
||||||
|
icons,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
adapter: new ValibotJsonSchemaAdapter(),
|
adapter: new ValibotJsonSchemaAdapter(),
|
||||||
@@ -21,10 +22,18 @@ export const server = new McpServer(
|
|||||||
instructions:
|
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.',
|
'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> }>();
|
).withContext<{
|
||||||
|
track?: (sessionId: string, event: string, extra?: string) => Promise<void>;
|
||||||
|
stdio?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
export type SvelteMcp = typeof server;
|
export type SvelteMcp = typeof server;
|
||||||
|
|
||||||
setup_tools(server);
|
setup_tools(server);
|
||||||
setup_resources(server);
|
setup_resources(server);
|
||||||
setup_prompts(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);
|
||||||
|
});
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ export async function get_sections() {
|
|||||||
export async function format_sections_list() {
|
export async function format_sections_list() {
|
||||||
const sections = await get_sections();
|
const sections = await get_sections();
|
||||||
return sections
|
return sections
|
||||||
.map((s) => `* title: ${s.title}, use_cases: ${s.use_cases}, path: ${s.slug}`)
|
.map((s) => `- title: ${s.title}, use_cases: ${s.use_cases}, path: ${s.slug}`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
import ts_parser from '@typescript-eslint/parser';
|
import ts_parser from '@typescript-eslint/parser';
|
||||||
|
import type * as eslint from 'eslint';
|
||||||
import type { CallExpression, Identifier } from 'estree';
|
import type { CallExpression, Identifier } from 'estree';
|
||||||
import type { Reference, Variable } from 'eslint-scope';
|
|
||||||
import { parseForESLint as svelte_eslint_parse } from 'svelte-eslint-parser';
|
import { parseForESLint as svelte_eslint_parse } from 'svelte-eslint-parser';
|
||||||
import { runes } from '../constants.js';
|
import { runes } from '../constants.js';
|
||||||
|
|
||||||
type Scope = {
|
type Scope = eslint.Scope.Scope;
|
||||||
variables?: Variable[];
|
type ScopeManager = eslint.Scope.ScopeManager;
|
||||||
references?: Reference[];
|
|
||||||
childScopes?: Scope[];
|
|
||||||
};
|
|
||||||
type ScopeManager = {
|
|
||||||
globalScope: Scope;
|
|
||||||
};
|
|
||||||
|
|
||||||
function collect_scopes(scope: Scope, acc: Scope[] = []) {
|
function collect_scopes(scope: Scope, acc: Scope[] = []) {
|
||||||
acc.push(scope);
|
acc.push(scope);
|
||||||
@@ -27,17 +21,27 @@ export function parse(code: string, file_path: string) {
|
|||||||
parser: { ts: ts_parser, typescript: ts_parser },
|
parser: { ts: ts_parser, typescript: ts_parser },
|
||||||
});
|
});
|
||||||
let all_scopes: Scope[] | undefined;
|
let all_scopes: Scope[] | undefined;
|
||||||
let all_variables: Variable[] | undefined;
|
let all_variables: eslint.Scope.Variable[] | undefined;
|
||||||
let all_references: Reference[] | undefined;
|
let all_references: eslint.Scope.Reference[] | undefined;
|
||||||
|
|
||||||
function get_all_scopes() {
|
function get_all_scopes() {
|
||||||
if (!all_scopes) {
|
if (!all_scopes) {
|
||||||
all_scopes = collect_scopes(parsed.scopeManager!.globalScope);
|
all_scopes = collect_scopes(parsed.scopeManager!.globalScope!);
|
||||||
}
|
}
|
||||||
return all_scopes;
|
return all_scopes;
|
||||||
}
|
}
|
||||||
|
// walking the ast will also walk all the tokens if we don't remove them so we return them separately
|
||||||
|
// we also remove the parent which as a circular reference to the ast itself (and it's not needed since we use zimmerframe to walk the ast)
|
||||||
|
const {
|
||||||
|
ast: { tokens, ...ast },
|
||||||
|
} = parsed;
|
||||||
|
|
||||||
|
// @ts-expect-error we also have to delete it from the object or the circular reference remains
|
||||||
|
delete parsed.ast.tokens;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ast: parsed.ast,
|
ast,
|
||||||
|
tokens,
|
||||||
scope_manager: parsed.scopeManager as ScopeManager,
|
scope_manager: parsed.scopeManager as ScopeManager,
|
||||||
visitor_keys: parsed.visitorKeys,
|
visitor_keys: parsed.visitorKeys,
|
||||||
get all_scopes() {
|
get all_scopes() {
|
||||||
@@ -59,6 +63,8 @@ export function parse(code: string, file_path: string) {
|
|||||||
return this.all_references.find((r) => r.identifier === id);
|
return this.all_references.find((r) => r.identifier === id);
|
||||||
},
|
},
|
||||||
is_rune(call: CallExpression, rune?: (typeof runes)[number][]) {
|
is_rune(call: CallExpression, rune?: (typeof runes)[number][]) {
|
||||||
|
// it should always be a call expression but we check just in case because sometimes it's any and TS doesn't complain
|
||||||
|
if (call.type !== 'CallExpression') return false;
|
||||||
if (call.callee.type !== 'Identifier' && call.callee.type !== 'MemberExpression')
|
if (call.callee.type !== 'Identifier' && call.callee.type !== 'MemberExpression')
|
||||||
return false;
|
return false;
|
||||||
const id = call.callee.type === 'Identifier' ? call.callee : call.callee.object;
|
const id = call.callee.type === 'Identifier' ? call.callee : call.callee.object;
|
||||||
|
|||||||
@@ -1,49 +1,209 @@
|
|||||||
# @sveltejs/mcp
|
# @sveltejs/mcp
|
||||||
|
|
||||||
|
## 0.1.25
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: better wording for `desired_svelte_version` ([`59dcbff`](https://github.com/sveltejs/ai-tools/commit/59dcbff136a91efad5a0e978e8208e1b1d277f97))
|
||||||
|
|
||||||
|
## 0.1.24
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- chore: support declaration tags ([#222](https://github.com/sveltejs/ai-tools/pull/222))
|
||||||
|
|
||||||
|
## 0.1.23
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- feat: allow stdio mcp to read the content of the file directly ([#198](https://github.com/sveltejs/ai-tools/pull/198))
|
||||||
|
|
||||||
|
- fix: handle non call expressions passed to `is_rune` ([#201](https://github.com/sveltejs/ai-tools/pull/201))
|
||||||
|
|
||||||
|
- chore: remove db requirement ([#196](https://github.com/sveltejs/ai-tools/pull/196))
|
||||||
|
|
||||||
|
## 0.1.22
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: broaden checks for imported runes because LLMs are unhinged ([#185](https://github.com/sveltejs/ai-tools/pull/185))
|
||||||
|
|
||||||
|
## 0.1.21
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- feat: display similar result & error at the end ([#161](https://github.com/sveltejs/ai-tools/pull/161))
|
||||||
|
|
||||||
|
## 0.1.20
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: turn off no-inspect in eslint for mcp ([`2245cb2`](https://github.com/sveltejs/ai-tools/commit/2245cb2dc9e2d217869b6a800795ce59ffb40c51))
|
||||||
|
|
||||||
|
## 0.1.19
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- chore: update svelte ([`7447744`](https://github.com/sveltejs/ai-tools/commit/74477448cea44ec21684ea4d39f2c5c7133b5150))
|
||||||
|
|
||||||
|
## 0.1.18
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- feat: expose playground link as MCP App ([#138](https://github.com/sveltejs/ai-tools/pull/138))
|
||||||
|
|
||||||
|
## 0.1.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: add suggestion for snippets declared in script tag ([#132](https://github.com/sveltejs/ai-tools/pull/132))
|
||||||
|
|
||||||
|
## 0.1.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- feat: expose tools as JS api + cli ([#128](https://github.com/sveltejs/ai-tools/pull/128))
|
||||||
|
|
||||||
|
## 0.1.15
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: server.json version + update publisher ([`9dfb4de`](https://github.com/sveltejs/ai-tools/commit/9dfb4dedb42837c40c4e660f0f816d7cf9081fc4))
|
||||||
|
|
||||||
|
## 0.1.14
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: improve prompt to reduce token usage ([#124](https://github.com/sveltejs/ai-tools/pull/124))
|
||||||
|
|
||||||
|
## 0.1.13
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: revert name change and add title ([`98efa1e`](https://github.com/sveltejs/ai-tools/commit/98efa1e09ebcca7827b10dc6bc8e1699fc1e5171))
|
||||||
|
|
||||||
|
## 0.1.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: update server name on mcp registry ([`60297b3`](https://github.com/sveltejs/ai-tools/commit/60297b3c49bf110b48908e61b5d5d902ea1bdf39))
|
||||||
|
|
||||||
|
- chore: update tmcp ([#99](https://github.com/sveltejs/ai-tools/pull/99))
|
||||||
|
|
||||||
|
## 0.1.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: add `async` parameter to `svelte-autofixer` ([#94](https://github.com/sveltejs/ai-tools/pull/94))
|
||||||
|
|
||||||
|
- fix: install latest eslint svelte packages to support `$state.eager` ([`f6ce89f`](https://github.com/sveltejs/ai-tools/commit/f6ce89ff34faabc3d746a350ea347298ecfed2ec))
|
||||||
|
|
||||||
|
## 0.1.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: add icons to `server.json` ([`02c951b`](https://github.com/sveltejs/ai-tools/commit/02c951baa86ac8103ffc158a202c06cfe6b15c01))
|
||||||
|
|
||||||
|
- fix: add `preferred-frame-size` to UI resource ([`3fabcc0`](https://github.com/sveltejs/ai-tools/commit/3fabcc0f9bfee916c0deb9c2ffa931ed2168af2d))
|
||||||
|
|
||||||
|
- feat: support: `$state.eager` ([#90](https://github.com/sveltejs/ai-tools/pull/90))
|
||||||
|
|
||||||
|
## 0.1.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- feat: return `mcp-ui` resource from `playground-link` ([#84](https://github.com/sveltejs/ai-tools/pull/84))
|
||||||
|
|
||||||
|
- feat: suggest against js variables in css ([#78](https://github.com/sveltejs/ai-tools/pull/78))
|
||||||
|
|
||||||
|
## 0.1.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: upgrade registry publisher cli ([`5fa2baa`](https://github.com/sveltejs/ai-tools/commit/5fa2baa27009f01e0e4e91cee7984b81a81c1c29))
|
||||||
|
|
||||||
|
## 0.1.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: use correct server schema version ([`579be87`](https://github.com/sveltejs/ai-tools/commit/579be877fa9f87f7f173450ca5bc918824d68282))
|
||||||
|
|
||||||
|
## 0.1.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: prevent `imported_runes` suggestion from being added for libs that are not svelte ([`87af64f`](https://github.com/sveltejs/ai-tools/commit/87af64f4bc6d07b75640eb987a33655654363997))
|
||||||
|
|
||||||
|
- feat: add svelte icon and website url for mcp server ([#75](https://github.com/sveltejs/ai-tools/pull/75))
|
||||||
|
|
||||||
|
- fix: use `data:` uri for local icon & add icons to tools + resources + prompts ([`cf62286`](https://github.com/sveltejs/ai-tools/commit/cf622869129382a97ad059bb1389f115907adc8e))
|
||||||
|
|
||||||
|
## 0.1.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: widen `desired_svelte_version` validation to accommodate some clients ([`3b301d7`](https://github.com/sveltejs/ai-tools/commit/3b301d7d9c2f49758023408f505bc4ca79caaff4))
|
||||||
|
|
||||||
|
- fix: minor tweaks to the prompt to allow for automatic sync ([#63](https://github.com/sveltejs/ai-tools/pull/63))
|
||||||
|
|
||||||
|
- feat: `read_state_with_dollar` autofixer ([#66](https://github.com/sveltejs/ai-tools/pull/66))
|
||||||
|
|
||||||
|
## 0.1.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: pass secrets in action and update `mcpName` ([`044f098`](https://github.com/sveltejs/ai-tools/commit/044f0988b935fff39911a861a648dfb276f5831a))
|
||||||
|
|
||||||
|
## 0.1.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- fix: use DNS to publish MCP ([#59](https://github.com/sveltejs/ai-tools/pull/59))
|
||||||
|
|
||||||
## 0.1.2
|
## 0.1.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- fix: publish to MCP registry (I really hope this time for real) ([`ef5241c`](https://github.com/sveltejs/mcp/commit/ef5241cbc204ad8bb84bde27db7c9d0a08280245))
|
- fix: publish to MCP registry (I really hope this time for real) ([`ef5241c`](https://github.com/sveltejs/ai-tools/commit/ef5241cbc204ad8bb84bde27db7c9d0a08280245))
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- feat: publish mcp to registry (maybe for real this time) ([`132943d`](https://github.com/sveltejs/mcp/commit/132943db3b04dbbd322d08926c0880c990a61f5f))
|
- feat: publish mcp to registry (maybe for real this time) ([`132943d`](https://github.com/sveltejs/ai-tools/commit/132943db3b04dbbd322d08926c0880c990a61f5f))
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
- feat: publish to registry ([#45](https://github.com/sveltejs/mcp/pull/45))
|
- feat: publish to registry ([#45](https://github.com/sveltejs/ai-tools/pull/45))
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- feat: add autofixer to tell the LLM to check if some function called in effect is assigning state #26 ([`73d7625`](https://github.com/sveltejs/mcp/commit/73d7625b3ca6a812ba91883ea668d80ff1e7c703))
|
- feat: add autofixer to tell the LLM to check if some function called in effect is assigning state #26 ([`73d7625`](https://github.com/sveltejs/ai-tools/commit/73d7625b3ca6a812ba91883ea668d80ff1e7c703))
|
||||||
|
|
||||||
- feat: add bind:this -> attachment and action -> attachment autofixer #20 ([`73d7625`](https://github.com/sveltejs/mcp/commit/73d7625b3ca6a812ba91883ea668d80ff1e7c703))
|
- feat: add bind:this -> attachment and action -> attachment autofixer #20 ([`73d7625`](https://github.com/sveltejs/ai-tools/commit/73d7625b3ca6a812ba91883ea668d80ff1e7c703))
|
||||||
|
|
||||||
## 0.0.4
|
## 0.0.4
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- fix: allow TS `.svelte.ts` modules ([#49](https://github.com/sveltejs/mcp/pull/49))
|
- fix: allow TS `.svelte.ts` modules ([#49](https://github.com/sveltejs/ai-tools/pull/49))
|
||||||
|
|
||||||
## 0.0.3
|
## 0.0.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- fix: check effect.pre in assign-in-effect ([#41](https://github.com/sveltejs/mcp/pull/41))
|
- fix: check effect.pre in assign-in-effect ([#41](https://github.com/sveltejs/ai-tools/pull/41))
|
||||||
|
|
||||||
- feat: `use_cases` documentation metadata ([#29](https://github.com/sveltejs/mcp/pull/29))
|
- feat: `use_cases` documentation metadata ([#29](https://github.com/sveltejs/ai-tools/pull/29))
|
||||||
|
|
||||||
- fix: change title names to allow for claude code to use the prompt ([`725f785`](https://github.com/sveltejs/mcp/commit/725f785766d04e9ed810a7c3f6bcfdb2e2b8234c))
|
- fix: change title names to allow for claude code to use the prompt ([`725f785`](https://github.com/sveltejs/ai-tools/commit/725f785766d04e9ed810a7c3f6bcfdb2e2b8234c))
|
||||||
|
|
||||||
- fix: enable doc tools ([`cb316c5`](https://github.com/sveltejs/mcp/commit/cb316c5b3ebc712946969d2d57236d159e796d58))
|
- fix: enable doc tools ([`cb316c5`](https://github.com/sveltejs/ai-tools/commit/cb316c5b3ebc712946969d2d57236d159e796d58))
|
||||||
|
|
||||||
## 0.0.2
|
## 0.0.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
- feat: latest version ([#25](https://github.com/sveltejs/mcp/pull/25))
|
- feat: latest version ([#25](https://github.com/sveltejs/ai-tools/pull/25))
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
4e7c92f289d903d4649c59f82df6e7b014caebb49d8b5c1d2466667fd6caf68c mcp-publisher_1.2.3_darwin_amd64.tar.gz
|
|
||||||
09637600871bec7cce25e098d6ce23b7c7577a8e537f618d24a5630d2d782afa mcp-publisher_1.2.3_darwin_amd64.tar.gz.sbom.json
|
|
||||||
9ac90d3182bae9af4b48fb3cd19c3cade3e52c8ea25d7aa14327326a209bcf71 mcp-publisher_1.2.3_darwin_arm64.tar.gz
|
|
||||||
0b2cedf3f42c5a7b33bdd3f72ce7f4c938ff4fe2aca5cabd60094dc4b855c1f6 mcp-publisher_1.2.3_darwin_arm64.tar.gz.sbom.json
|
|
||||||
868a54268f21580ec97ec9dfc4fc3442a7f69c241ee7c745c7032f2e43cdf47b mcp-publisher_1.2.3_linux_amd64.tar.gz
|
|
||||||
a7bce190ea1c1b5682d1b5069b20dd9c67f3688e02dbc93e7273e942097dac4d mcp-publisher_1.2.3_linux_amd64.tar.gz.sbom.json
|
|
||||||
319cdefb4c4f19fa35eeb0337e30be3169dbf3107a8c160651691a6342a6783b mcp-publisher_1.2.3_linux_arm64.tar.gz
|
|
||||||
bc9309ab843531e811990dcf637b9912c470fc38eddc13a5af0512fcef498944 mcp-publisher_1.2.3_linux_arm64.tar.gz.sbom.json
|
|
||||||
298026e0252547046f50dcb7817239d44107f5a3ae64f4e43b6a31d0c5b89f9b mcp-publisher_1.2.3_windows_amd64.tar.gz
|
|
||||||
971b835ce4df2b37ddcf8591d4400dc94d1e3f730b181b325c905261b75b9e6e mcp-publisher_1.2.3_windows_amd64.tar.gz.sbom.json
|
|
||||||
64da67b451d0fba12f15f7b0f6ab8d71c718bb2263f90f198ff1fe15a5ff2024 mcp-publisher_1.2.3_windows_arm64.tar.gz
|
|
||||||
f591b2153f1277cb67817763a23de9e77188fa94b893fac00e91d13160d696e3 mcp-publisher_1.2.3_windows_arm64.tar.gz.sbom.json
|
|
||||||
265377b343500898e3c3fea798926ff2695fe7500c1225c8a97f390a5892d849 registry-1.2.3.tar.gz
|
|
||||||
a9c03a84d2e30176d6ed7b493e7e3a8a05d446f1611a35bad6007fbe3ba80657 registry_1.2.3_darwin_amd64.tar.gz
|
|
||||||
4db4e8a0b1f3d0ca193e5356fef89b74c0666cdf56d6f3c8fc2d0aba1cac3b55 registry_1.2.3_darwin_amd64.tar.gz.sbom.json
|
|
||||||
2933a11990db16035e4896f394ada389166046911e6868f79b84636048dfe6fb registry_1.2.3_darwin_arm64.tar.gz
|
|
||||||
edd36e62f4b1c5b857da1862f20cbcf6dd3dfd9717888c08bd5c25740d8b11f6 registry_1.2.3_darwin_arm64.tar.gz.sbom.json
|
|
||||||
59bdd9977795891220e6fdb8f79dd7d14f48166362e94699bee59e745f7c7df6 registry_1.2.3_linux_amd64.tar.gz
|
|
||||||
7f7efb180aa312f674377e32a92ac3600e50c62e37d697d2d16acfe60227a2fd registry_1.2.3_linux_amd64.tar.gz.sbom.json
|
|
||||||
7fef1088a664850dd75e54a699fce6a5fb32e8ebbdc0d2869b6b34945727ba9c registry_1.2.3_linux_arm64.tar.gz
|
|
||||||
ca0488e5cbb04c8ee515e1b80e08b755a55d6af1784368a2f55e429137359a25 registry_1.2.3_linux_arm64.tar.gz.sbom.json
|
|
||||||
5bc29310aacc08437dcc973cfc1e1129f7065d2050396012f5ed98c4eb0ea75b registry_1.2.3_windows_amd64.tar.gz
|
|
||||||
e918c604f23e6d33f9952f18eddf0e50e50d7ce3e87ca5258bf78f4f1da243ab registry_1.2.3_windows_amd64.tar.gz.sbom.json
|
|
||||||
394cad1e6f5e37a583defdd522edbff854de5035d6e025a195664db31b58c0c0 registry_1.2.3_windows_arm64.tar.gz
|
|
||||||
c93df66f3257ba4b9c29f7bfded4cf04d712ec220b044ddfa019da3e4bd6475f registry_1.2.3_windows_arm64.tar.gz.sbom.json
|
|
||||||
25
packages/mcp-stdio/checksums/registry_1.4.0_checksums.txt
Normal file
25
packages/mcp-stdio/checksums/registry_1.4.0_checksums.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
eb5f89b76fc45a97070fa481eb03977584a78e3dff2781402d43482f114e4d6a mcp-publisher_darwin_amd64.tar.gz
|
||||||
|
29fc1b46a6f6be2580129369a9b681204b11b425d9a44147d79c8c658c7b8474 mcp-publisher_darwin_amd64.tar.gz.sbom.json
|
||||||
|
9eddbbb95efd54b9503f6c0668f43bab3f04c856946d3c7164f6daead232402f mcp-publisher_darwin_arm64.tar.gz
|
||||||
|
a8349b0ea7916f34cf4ee4e1ced5b91bc1ded6d100312cbb2095da018710da04 mcp-publisher_darwin_arm64.tar.gz.sbom.json
|
||||||
|
c4b402b43a85166c3f840641ca1c9e6de5bfa1cf533c22576d663ccbda0711bb mcp-publisher_linux_amd64.tar.gz
|
||||||
|
6f21cf917055be885f16b93154e06379540236599cfad6af4404a8323bde74b7 mcp-publisher_linux_amd64.tar.gz.sbom.json
|
||||||
|
ba5d486f86b2cef48ea506e8314d901a5169dcd56a5d6e9daf18d41244316235 mcp-publisher_linux_arm64.tar.gz
|
||||||
|
8a0096a407b916ac7270732df017a26f6112c73a066252f6556b8956c492a0b4 mcp-publisher_linux_arm64.tar.gz.sbom.json
|
||||||
|
59ee8c4a997f94794db8db13f8809666631686a70a8d89a9f0fea993f9aede0f mcp-publisher_windows_amd64.tar.gz
|
||||||
|
57d211fd9181f698d126bd773b55c98b92454d19b1e32e77860766179a8a2e8e mcp-publisher_windows_amd64.tar.gz.sbom.json
|
||||||
|
1410952b0a5968cbe89590e7b4ee6105147ef7267cf0cd50095c9bec2ee3b0d7 mcp-publisher_windows_arm64.tar.gz
|
||||||
|
6cb93e118a89ed1419135bfbaa7401bd3b7a7c5680a0d8fd7c78728f9d860630 mcp-publisher_windows_arm64.tar.gz.sbom.json
|
||||||
|
ebc17c3b7a5b86f9c036acf1d44fb904bb363bad0ac1ac37b7979eb17cf3d218 registry-1.4.0.tar.gz
|
||||||
|
5fffe8b078513fa5fbb625a213d164bb391c7c85e216e541cab789517bc6365b registry_darwin_amd64.tar.gz
|
||||||
|
10a61cf4173d8b5be63044af0a10e6c809eebc1006c0c1643753a252db808ddd registry_darwin_amd64.tar.gz.sbom.json
|
||||||
|
437746a1045f093266ad7298a47be41dc44cc33ecaeec145449c4eefeddf8880 registry_darwin_arm64.tar.gz
|
||||||
|
4c0cb24bcef0658540fb044d771294efd662edecd2f7fae7b1ca7ca2ae68f83a registry_darwin_arm64.tar.gz.sbom.json
|
||||||
|
bd77fafcc881714a63a375a9bdb53a761a2b8e367a9d2759835126c993df2356 registry_linux_amd64.tar.gz
|
||||||
|
d62a461b174089fbcaa4f1ac096bca491d18bc7f70e93ce0824fe89dbe42e974 registry_linux_amd64.tar.gz.sbom.json
|
||||||
|
38cb9e6112ff11544ba8ec88c5c0f44d4c851504ec2e33d497e25616a6f7a21e registry_linux_arm64.tar.gz
|
||||||
|
84e5a004929e7231ae35350a1fe8fb08668fc05183e13d1d78004abf08a25f3b registry_linux_arm64.tar.gz.sbom.json
|
||||||
|
77ca9243d2f744f282b39d07625f802d77f593850a0392debabe407643a8579c registry_windows_amd64.tar.gz
|
||||||
|
bb043e8a6a8d187ffab8987d36d0018024115d9217af6d2ddd233f94aea880ea registry_windows_amd64.tar.gz.sbom.json
|
||||||
|
e4ee50e05a95f288b874f5e24c7716a5032548feeabc83b715193298cec06890 registry_windows_arm64.tar.gz
|
||||||
|
49f189b615bce3d09ea24ae5d80e0816ac69225b3c8901dd7be19ef9ca06830c registry_windows_arm64.tar.gz.sbom.json
|
||||||
@@ -1,24 +1,30 @@
|
|||||||
{
|
{
|
||||||
"name": "@sveltejs/mcp",
|
"name": "@sveltejs/mcp",
|
||||||
"version": "0.1.2",
|
"version": "0.1.25",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"mcpName": "io.github.sveltejs/svelte",
|
"mcpName": "dev.svelte/mcp",
|
||||||
"homepage": "https://github.com/sveltejs/mcp#readme",
|
"homepage": "https://github.com/sveltejs/ai-tools#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/sveltejs/mcp/issues"
|
"url": "https://github.com/sveltejs/ai-tools/issues"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"svelte-mcp": "./dist/index.js"
|
"svelte-mcp": "./dist/index.mjs"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/sveltejs/mcp.git",
|
"url": "git+https://github.com/sveltejs/ai-tools.git",
|
||||||
"path": "packages/mcp-stdio"
|
"path": "packages/mcp-stdio"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/handlers.d.mts",
|
||||||
|
"import": "./dist/handlers.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -32,14 +38,16 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/mcp-server": "workspace:^",
|
"@sveltejs/mcp-server": "workspace:^",
|
||||||
"@tmcp/transport-stdio": "^0.3.1",
|
"@tmcp/transport-stdio": "catalog:tmcp",
|
||||||
"@types/node": "^22.15.17",
|
"@types/node": "catalog:tooling",
|
||||||
"publint": "^0.3.13",
|
"publint": "catalog:tooling",
|
||||||
"tsdown": "^0.15.0",
|
"tsdown": "catalog:tooling",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "catalog:tooling",
|
||||||
"vitest": "^3.1.3"
|
"vitest": "catalog:tooling"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"eslint": "^9.36.0"
|
"eslint": "catalog:lint",
|
||||||
|
"sade": "catalog:tooling",
|
||||||
|
"tmcp": "catalog:tmcp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,31 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
||||||
"name": "io.github.sveltejs/svelte",
|
"name": "dev.svelte/mcp",
|
||||||
|
"title": "Svelte MCP",
|
||||||
"description": "The official Svelte MCP server providing docs and autofixing tools for Svelte development",
|
"description": "The official Svelte MCP server providing docs and autofixing tools for Svelte development",
|
||||||
"repository": {
|
"repository": {
|
||||||
"id": "1054419133",
|
"id": "1054419133",
|
||||||
"url": "https://github.com/sveltejs/mcp",
|
"url": "https://github.com/sveltejs/ai-tools",
|
||||||
"subfolder": "packages/mcp-stdio",
|
"subfolder": "packages/mcp-stdio",
|
||||||
"source": "github"
|
"source": "github"
|
||||||
},
|
},
|
||||||
"version": "0.1.2",
|
"version": "0.1.25",
|
||||||
"websiteUrl": "https://svelte.dev/docs/mcp/overview",
|
"websiteUrl": "https://svelte.dev/docs/mcp/overview",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "https://mcp.svelte.dev/logo.svg",
|
||||||
|
"mimeType": "image/svg+xml"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "https://mcp.svelte.dev/logo.png",
|
||||||
|
"mimeType": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registryType": "npm",
|
"registryType": "npm",
|
||||||
"identifier": "@sveltejs/mcp",
|
"identifier": "@sveltejs/mcp",
|
||||||
"version": "0.1.2",
|
"version": "0.1.25",
|
||||||
"runtimeHint": "npx",
|
"runtimeHint": "npx",
|
||||||
"transport": {
|
"transport": {
|
||||||
"type": "stdio"
|
"type": "stdio"
|
||||||
|
|||||||
6
packages/mcp-stdio/src/handlers.ts
Normal file
6
packages/mcp-stdio/src/handlers.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export {
|
||||||
|
list_sections_handler as listSections,
|
||||||
|
get_documentation_handler as getDocumentation,
|
||||||
|
svelte_autofixer_handler as svelteAutofixer,
|
||||||
|
playground_link_handler as playgroundLink,
|
||||||
|
} from '@sveltejs/mcp-server/handlers';
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user