10. Language model tools for VS Code chat

The extension contributes languageModelTools in package.json and registers them with vscode.lm.registerTool (AI-12).

Esta página está em inglês; a tradução está a caminho.

10.1 Contributed tools#

The extension contributes languageModelTools in package.json and registers them with vscode.lm.registerTool (AI-12). Names and input schemas are the Figma tool names and schemas, as in §5.2.

Tool name toolReferenceName Mutates Confirmation
use_figma udUseFigma yes yes: “Run script on app.design: ” with the code in the details
get_metadata udMetadata no no
get_screenshot udScreenshot no no
get_design_context udDesignContext no no
get_variable_defs udVariables no no
search_design_system udSearchDesignSystem no no

Users reference them in chat as #udUseFigma etc., or group them with the tool set #uiDesigner. Each tool’s modelDescription carries a short form of the ui-designer gotchas (colours 0–1, load fonts, clone paints, return ids), because chat agents do not load skills.

10.2 Behaviour#

  • Calls run in the extension host against the open editor (no bridge needed), or headless when the file is not open. Each use_figma is one undo step signed with the chat agent’s name (Copilot for Copilot agent mode; else ud.ai.lm.actor, default Chat agent).
  • prepareInvocation shows the confirmation for mutating calls; VS Code’s “always allow” applies per workspace.
  • Screenshots are returned as LanguageModelDataPart images; text as LanguageModelTextPart.
  • Licence as in §5.6: the tools are gated like ud, not as “AI features” — reads work on every plan, use_figma needs the plan ud needs for a mutation and otherwise returns a licence error. ud.ai.enabled applies too: with AI disabled, the tools are not registered.
  • The AI panel’s proposals do not apply to chat agents (AI-5 covers the panel, §6.5); their changes are reviewable through history, ud diff and undo, and the confirmation above shows the script first.

10.3 vscode.lm as the panel’s backend#

When ud.ai.backend is vscode-lm (or Claude Code is unavailable), the panel runs its own tool loop with vscode.lm.selectChatModels and sendRequest, offering the same tools as §5.2 (in-process) and the bundled ui-designer skill text as the system prompt. Proposals, limits, Cancel and review work the same. Read-only workspace tools are provided in-process (read file, search). Quality depends on the selected model; the scenario suite (§12) is run against it as a separate, non-blocking column.