Preload Copilot skills in project editor#3080
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a "Skills" system for the Copilot, enabling it to dynamically load domain-specific knowledge such as SPX project guidelines and XGo language syntax via new tools. It refactors the Copilot architecture by moving editor-specific tools and context providers from the root component into a dedicated useSpxEditorCopilot hook and updates the core Copilot class to support asynchronous context providers and raw string tool results. Feedback focuses on correcting typos and package categorization in the new skill documentation, as well as optimizing the skill registry by caching record lookups to improve performance.
| @@ -36,13 +35,3 @@ export function createBuiltInSkillRegistry(): SkillRegistry { | |||
| } | |||
| return registry | |||
| } | |||
|
|
|||
| /** Register built-in skill support to the given Copilot instance. */ | |||
| export function registerSkillSupport(copilot: Copilot): Disposer { | |||
There was a problem hiding this comment.
skill support 内置到 class Copilot 中了
| ? 'The signed-in state is still loading' | ||
| : signedInState.isSignedIn | ||
| ? `Now the user is signed in with name "${signedInState.user.username}"` | ||
| ? `Now the user is signed in as "${signedInState.user.username}", with display name: "${signedInState.user.displayName}"` |
There was a problem hiding this comment.
这个改动跟这个 PR 关系不大,只是测试时遇到 displayName 和 username 不同时,copilot 可能会误判项目是否属于当前用户。因此这里把 displayName 和 username 都带上
There was a problem hiding this comment.
Pull request overview
This PR preloads built-in Copilot skills for the SPX project editor so framework/project guidance is available immediately in the editor Copilot context, and adds deduping to avoid reloading already-preloaded skills.
Changes:
- Preload
xgo-language+spx-projectskills from the SPX editor Copilot context provider. - Move skill catalog + preload-skill context injection into
Copilot, and skipload_skillwhen the skill is already preloaded. - Update/add focused tests for skill catalog formatting, preload behavior, and tool deduping.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spx-gui/src/components/editor/copilot/index.ts | Registers a context provider that preloads xgo-language and spx-project in the editor context. |
| spx-gui/src/components/copilot/skills/tools.ts | Adds “already preloaded” short-circuit to load_skill and factors out skill-content wrapping. |
| spx-gui/src/components/copilot/skills/skills.test.ts | Updates tests to exercise skill catalog + preload context via Copilot, and verifies dedupe behavior. |
| spx-gui/src/components/copilot/skills/context-provider.ts | Removes standalone skill catalog provider (now handled in Copilot). |
| spx-gui/src/components/copilot/skills/content.ts | New shared helper to wrap/escape skill content + resource paths. |
| spx-gui/src/components/copilot/skills/built-in.ts | Exposes skill name constants; removes registerSkillSupport helper. |
| spx-gui/src/components/copilot/copilot.ts | Integrates skill catalog + preload context building into core Copilot flow; registers skill tools in ctor. |
| spx-gui/src/components/copilot/copilot.test.ts | Updates constructor usage and expectations due to built-in skill tools always being registered. |
| spx-gui/src/components/copilot/CopilotRoot.vue | Creates built-in registry and passes into Copilot; removes old skill-support registration path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #3045, based on #3047.
Summary
xgo-languageandspx-projectin the SPX editor Copilot contextValidation
npx vitest --run src/components/copilot/skills/skills.test.ts